File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,13 @@ def url2pathname(url):
2626 # Skip past extra slash before UNC drive in URL path.
2727 url = url [1 :]
2828 # Windows itself uses ":" even in URLs.
29- url = url .replace (':' , '|' )
30- if not '|' in url :
29+ url = url .replace (':' , '|' , 1 )
30+ if not '|' in url or ('|' in url and not (
31+ url .startswith ('|' ) or
32+ '/|' in url or
33+ (len (url ) > 2 and url [0 ] == '/' and url [2 ] == '|' and url [1 ].isalpha ()))
34+ ):
35+ url = url .replace ('|' , ':' , 1 )
3136 # No drive specifier, just convert slashes
3237 # make sure not to convert quoted slashes :-)
3338 return urllib .parse .unquote (url .replace ('/' , '\\ ' ))
Original file line number Diff line number Diff line change @@ -1509,6 +1509,9 @@ def test_url2pathname_win(self):
15091509 # Percent-encoded forward slashes are preserved for backwards compatibility
15101510 self .assertEqual (fn ('C:/foo%2fbar' ), 'C:\\ foo/bar' )
15111511 self .assertEqual (fn ('//server/share/foo%2fbar' ), '\\ \\ server\\ share\\ foo/bar' )
1512+ # Colon in filenames, both with drive specifier and without
1513+ self .assertEqual (fn ('//host/path/spam.foo:bar' ), '\\ \\ host\\ path\\ spam.foo:bar' )
1514+ self .assertEqual (fn ('///c:/path/spam.foo:bar' ), 'c:\\ path\\ spam.foo:bar' )
15121515 # Round-tripping
15131516 paths = ['C:' ,
15141517 r'\C\test\\' ,
You can’t perform that action at this time.
0 commit comments