mirror of
https://github.com/python/cpython.git
synced 2025-09-02 15:07:53 +00:00
[3.13] GH-126205: Fix conversion of UNC paths to file URIs (GH-126208) (#126249)
GH-126205: Fix conversion of UNC paths to file URIs (GH-126208)
File URIs for Windows UNC paths should begin with two slashes, not four.
(cherry picked from commit 951cb2c369
)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
parent
80042384b4
commit
588da2e26a
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