mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
GH-126205: Fix conversion of UNC paths to file URIs (#126208)
File URIs for Windows UNC paths should begin with two slashes, not four.
This commit is contained in:
parent
2b2d607095
commit
951cb2c369
3 changed files with 10 additions and 13 deletions
|
@ -55,16 +55,11 @@ def pathname2url(p):
|
|||
if p[:4] == '\\\\?\\':
|
||||
p = p[4:]
|
||||
if p[:4].upper() == 'UNC\\':
|
||||
p = '\\' + p[4:]
|
||||
p = '\\\\' + p[4:]
|
||||
elif p[1:2] != ':':
|
||||
raise OSError('Bad path: ' + p)
|
||||
if not ':' in p:
|
||||
# No drive specifier, just convert slashes and quote the name
|
||||
if p[:2] == '\\\\':
|
||||
# path is something like \\host\path\on\remote\host
|
||||
# convert this to ////host/path/on/remote/host
|
||||
# (notice doubling of slashes at the start of the path)
|
||||
p = '\\\\' + p
|
||||
components = p.split('\\')
|
||||
return urllib.parse.quote('/'.join(components))
|
||||
comp = p.split(':', maxsplit=2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue