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.url2pathname() mishandles a UNC URI variant #127078

Closed
barneygale opened this issue Nov 20, 2024 · 2 comments
Closed

urllib.request.url2pathname() mishandles a UNC URI variant #127078

barneygale opened this issue Nov 20, 2024 · 2 comments
Labels
3.12 bugs and security fixes 3.13 bugs and security fixes 3.14 new features, bugs and security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@barneygale
Copy link
Contributor

barneygale commented Nov 20, 2024

Bug report

Bug description:

On Windows, urllib.request.url2pathname() mishandles an uncommon file URI variant encoding a UNC path. Specifically, a URI with five leading slashes should be converted to a UNC path with two leading slashes, but url2pathname() returns a path with three leading slashes. Such URIs are created by software that simply prepends file:/// to a Windows path. See RFC 8089 E.3.2, final example.

>>> from urllib.request import url2pathname
>>> url2pathname('/////server/share')
'\\\\\\server\\share'  # expected: '\\\\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 stdlib Python modules in the Lib dir labels Nov 20, 2024
@barneygale
Copy link
Contributor Author

I think we should wait for #126367 to be fixed before tackling this bug

@barneygale
Copy link
Contributor Author

I think we should wait for #126367 to be fixed before tackling this bug

On second thought, it's better to solve this issue first to avoid backport conflicts.

barneygale added a commit to barneygale/cpython that referenced this issue Nov 22, 2024
…e in URL path

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
barneygale added a commit that referenced this issue Nov 22, 2024
…RL path (#127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 22, 2024
…e in URL path (pythonGH-127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
(cherry picked from commit 8c98ed8)

Co-authored-by: Barney Gale <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 22, 2024
…e in URL path (pythonGH-127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
(cherry picked from commit 8c98ed8)

Co-authored-by: Barney Gale <[email protected]>
barneygale added a commit that referenced this issue Nov 22, 2024
…ve in URL path (GH-127132) (#127135)

GH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (GH-127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
(cherry picked from commit 8c98ed8)

Co-authored-by: Barney Gale <[email protected]>
barneygale added a commit that referenced this issue Nov 22, 2024
…ve in URL path (GH-127132) (#127136)

GH-127078: `url2pathname()`: handle extra slash before UNC drive in URL path (GH-127132)

Decode a file URI like `file://///server/share` as a UNC path like
`\\server\share`. This form of file URI is created by software the simply
prepends `file:///` to any absolute Windows path.
(cherry picked from commit 8c98ed8)

Co-authored-by: Barney Gale <[email protected]>
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 stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant