Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib.request.pathname2url() mishandles UNC paths #126205

Open
barneygale opened this issue Oct 30, 2024 · 0 comments
Open

urllib.request.pathname2url() mishandles UNC paths #126205

barneygale opened this issue Oct 30, 2024 · 0 comments
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@barneygale
Copy link
Contributor

barneygale commented Oct 30, 2024

Bug report

Bug description:

When given a Windows UNC path, urllib.request.pathname2url() incorrectly generates a URI that begins with four slashes. The correct number is two, see ref1, ref2.

>>> import urllib.request
>>> urllib.request.pathname2url(r'\\server\share')
'////server/share'

Furthermore, when given an extended UNC path like \\?\unc\server\share, pathname2url() incorrectly generates a URI that begins with only one slash:

>>> urllib.request.pathname2url(r'\\?\unc\server\share')
'/server/share'

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

@barneygale barneygale added type-bug An unexpected behavior, bug, or error 3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels Oct 30, 2024
barneygale added a commit to barneygale/cpython that referenced this issue Oct 30, 2024
File URIs for Windows UNC paths should begin with two slashes, not four.
barneygale added a commit that referenced this issue Oct 30, 2024
File URIs for Windows UNC paths should begin with two slashes, not four.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant