python / cpython

The Python programming language
https://www.python.org
Other
63.72k stars 30.53k forks source link

pathname2url() does not work if path starts with // #127217

Closed serhiy-storchaka closed 4 days ago

serhiy-storchaka commented 5 days ago

Bug report

For example:

>>> from urllib.request import pathname2url
>>> 'file:' + pathname2url('//foo/bar')
'file://foo/bar'

This is a file URI with path "/bar" and authority "foo". Non-empty authority other than "localhost" are usually rejected. The right URI for path "//foo/bar" is "file:////foo/bar" -- an URI with explicit empty authority.

Similar bug in urlunparse() and urlunsplit() was fixed in #67693.

Linked PRs