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() raises on NTFS alternate data stream #126601

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

urllib.request.pathname2url() raises on NTFS alternate data stream #126601

barneygale opened this issue Nov 8, 2024 · 2 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 Nov 8, 2024

Bug report

Bug description:

On Windows, urllib.request.pathname2url() raises OSError when given a path with a colon in any position other than the second character. This excludes paths with NTFS alternate data streams, which are valid in other path-processing functions (e.g. in os.path and pathlib):

>>> from urllib.request import pathname2url
>>> pathname2url(r'C:\foo:bar')
OSError: Bad path: C:/foo:bar  # expected: ///C:/foo%3Abar
>>> pathname2url(r'foo:bar')
OSError: Bad path: foo:bar  # expected: foo%3Abar

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 Nov 8, 2024
@barneygale
Copy link
Contributor Author

Suggest we wait for #120423 to be fixed before tackling this one, as the required changes touch the same lines of code.

barneygale added a commit to barneygale/cpython that referenced this issue Nov 12, 2024
Adjust `pathname2url()` to encode embedded colon characters in Windows
paths, rather than bailing out with an `OSError`.
barneygale added a commit to barneygale/cpython that referenced this issue Nov 19, 2024
barneygale added a commit that referenced this issue Nov 22, 2024
)

Adjust `pathname2url()` to encode embedded colon characters in Windows
paths, rather than bailing out with an `OSError`.

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
@barneygale
Copy link
Contributor Author

Fixed in 3.14, but not backported as it's a pretty rare bug.

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