mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-127217: Fix pathname2url() for paths starting with multiple slashes on Posix (GH-127218)
This commit is contained in:
parent
2bb7846cac
commit
97b2ceaaaf
3 changed files with 9 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue