mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
[3.13] GH-126766: url2pathname()
: handle 'localhost' authority (GH-127129) (#127130)
GH-126766: `url2pathname()`: handle 'localhost' authority (GH-127129)
Discard any 'localhost' authority from the beginning of a `file:` URI. As a
result, file URIs like `//localhost/etc/hosts` are correctly decoded as
`/etc/hosts`.
(cherry picked from commit ebf564a1d3
)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
parent
8cdd636f87
commit
4b9068eeea
4 changed files with 15 additions and 5 deletions
|
@ -1660,6 +1660,9 @@ else:
|
|||
# URL has an empty authority section, so the path begins on the
|
||||
# third character.
|
||||
pathname = pathname[2:]
|
||||
elif pathname[:12] == '//localhost/':
|
||||
# Skip past 'localhost' authority.
|
||||
pathname = pathname[11:]
|
||||
encoding = sys.getfilesystemencoding()
|
||||
errors = sys.getfilesystemencodeerrors()
|
||||
return unquote(pathname, encoding=encoding, errors=errors)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue