mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
GH-126766: url2pathname()
: handle empty authority section. (#126767)
Discard two leading slashes from the beginning of a `file:` URI if they introduce an empty authority section. As a result, file URIs like `///etc/hosts` are correctly parsed as `/etc/hosts`.
This commit is contained in:
parent
47cbf03885
commit
cae9d9d20f
4 changed files with 14 additions and 9 deletions
|
@ -1656,6 +1656,10 @@ else:
|
|||
def url2pathname(pathname):
|
||||
"""OS-specific conversion from a relative URL of the 'file' scheme
|
||||
to a file system path; not recommended for general use."""
|
||||
if pathname[:3] == '///':
|
||||
# URL has an empty authority section, so the path begins on the
|
||||
# third character.
|
||||
pathname = pathname[2:]
|
||||
return unquote(pathname)
|
||||
|
||||
def pathname2url(pathname):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue