-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Comments
File URIs for Windows UNC paths should begin with two slashes, not four.
File URIs for Windows UNC paths should begin with two slashes, not four.
…26208) File URIs for Windows UNC paths should begin with two slashes, not four. (cherry picked from commit 951cb2c) Co-authored-by: Barney Gale <[email protected]>
…26208) File URIs for Windows UNC paths should begin with two slashes, not four. (cherry picked from commit 951cb2c) Co-authored-by: Barney Gale <[email protected]>
#126249) GH-126205: Fix conversion of UNC paths to file URIs (GH-126208) File URIs for Windows UNC paths should begin with two slashes, not four. (cherry picked from commit 951cb2c) Co-authored-by: Barney Gale <[email protected]>
#126248) GH-126205: Fix conversion of UNC paths to file URIs (GH-126208) File URIs for Windows UNC paths should begin with two slashes, not four. (cherry picked from commit 951cb2c) Co-authored-by: Barney Gale <[email protected]>
… POSIX paths When handed an absolute Windows path such as `C:\foo` or `//server/share`, the `urllib.request.pathname2url()` function returns a URL with an authority section, such as `///C:/foo` or `//server/share` (or before pythonGH-126205, `////server/share`). Only the `file:` prefix is omitted. But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows path of the same form (rooted but lacking a drive), the function returns a URL without an authority section, such as `/etc/hosts`. This patch corrects the discrepancy by adding a `//` prefix before drive-less, rooted paths when generating URLs.
I do not think the case for |
The former is considered "incorrect" and "unhealthy" by the Microsoft docs:
|
I can revert this in 3.12 and 3.13 if you think that's the right thing to do! |
No, I do not suggest to revert this in 3.12 and 3.13. The Microsoft docs talk about abominations like |
… path (#127194) When handed an absolute Windows path such as `C:\foo` or `//server/share`, the `urllib.request.pathname2url()` function returns a URL with an authority section, such as `///C:/foo` or `//server/share` (or before GH-126205, `////server/share`). Only the `file:` prefix is omitted. But when handed an absolute POSIX path such as `/etc/hosts`, or a Windows path of the same form (rooted but lacking a drive), the function returns a URL without an authority section, such as `/etc/hosts`. This patch corrects the discrepancy by adding a `//` prefix before drive-less, rooted paths when generating URLs.
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.Furthermore, when given an extended UNC path like
\\?\unc\server\share
,pathname2url()
incorrectly generates a URI that begins with only one slash:CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
The text was updated successfully, but these errors were encountered: