diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-11-24 17:30:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-24 17:30:29 (GMT) |
commit | 97b2ceaaaf88a73a45254912a0e972412879ccbf (patch) | |
tree | 0d103bb0bf447a581c49142da72c8293f87394fb /Lib/urllib | |
parent | 2bb7846cacb342246aada5ed92d323e54c946063 (diff) | |
download | cpython-97b2ceaaaf88a73a45254912a0e972412879ccbf.zip cpython-97b2ceaaaf88a73a45254912a0e972412879ccbf.tar.gz cpython-97b2ceaaaf88a73a45254912a0e972412879ccbf.tar.bz2 |
gh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix (GH-127218)
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 80be65c..9e55543 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1667,6 +1667,10 @@ else: def pathname2url(pathname): """OS-specific conversion from a file system path to a relative URL of the 'file' scheme; not recommended for general use.""" + if pathname[:2] == '//': + # Add explicitly empty authority to avoid interpreting the path + # as authority. + pathname = '//' + pathname encoding = sys.getfilesystemencoding() errors = sys.getfilesystemencodeerrors() return quote(pathname, encoding=encoding, errors=errors) |