mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
GH-126367: url2pathname(): handle NTFS alternate data streams (#131428)
Adjust `url2pathname()` to decode embedded colon characters in Windows URIs, rather than bailing out with an `OSError`.
This commit is contained in:
parent
01b5abbc53
commit
d783d7b51d
4 changed files with 20 additions and 17 deletions
|
|
@ -1484,6 +1484,7 @@ def test_pathname2url_nonascii(self):
|
|||
'test specific to Windows pathnames.')
|
||||
def test_url2pathname_win(self):
|
||||
fn = urllib.request.url2pathname
|
||||
self.assertEqual(fn('/'), '\\')
|
||||
self.assertEqual(fn('/C:/'), 'C:\\')
|
||||
self.assertEqual(fn("///C|"), 'C:')
|
||||
self.assertEqual(fn("///C:"), 'C:')
|
||||
|
|
@ -1502,8 +1503,10 @@ def test_url2pathname_win(self):
|
|||
self.assertEqual(fn('/C|/path/to/file'), 'C:\\path\\to\\file')
|
||||
self.assertEqual(fn('///C|/path/to/file'), 'C:\\path\\to\\file')
|
||||
self.assertEqual(fn("///C|/foo/bar/spam.foo"), 'C:\\foo\\bar\\spam.foo')
|
||||
# Non-ASCII drive letter
|
||||
self.assertRaises(IOError, fn, "///\u00e8|/")
|
||||
# Colons in URI
|
||||
self.assertEqual(fn('///\u00e8|/'), '\u00e8:\\')
|
||||
self.assertEqual(fn('//host/share/spam.txt:eggs'), '\\\\host\\share\\spam.txt:eggs')
|
||||
self.assertEqual(fn('///c:/spam.txt:eggs'), 'c:\\spam.txt:eggs')
|
||||
# UNC paths
|
||||
self.assertEqual(fn('//server/path/to/file'), '\\\\server\\path\\to\\file')
|
||||
self.assertEqual(fn('////server/path/to/file'), '\\\\server\\path\\to\\file')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue