-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
URLs supplied to urllib.request.url2pathname()
may include a non-empty authority (netloc), such as a hostname.
On Windows, these are correctly decoded (mostly):
>>> url2pathname('//localhost/c:/foo.txt')
'C:\\foo.txt' # OK
>>> url2pathname('//server/share')
'\\\\server\\share' # OK
But on POSIX, any non-empty authority except localhost
is preserved in the path:
>>> url2pathname('//myhostname/etc/hosts')
'//myhostname/etc/hosts' # expected '/etc/hosts'
>>> url2pathname('//server/share')
'//server/share' # expected URLError ('server' is not local)
Per RFC 8089 this isn't correct.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error