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 8c98ed846a)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-126766: `url2pathname()`: handle 'localhost' authority (GH-127129)
Discard any 'localhost' authority from the beginning of a `file:` URI. As a
result, file URIs like `//localhost/etc/hosts` are correctly decoded as
`/etc/hosts`.
(cherry picked from commit ebf564a1d3)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-126766: `url2pathname()`: handle empty authority section. (GH-126767)
Discard two leading slashes from the beginning of a `file:` URI if they
introduce an empty authority section. As a result, file URIs like
`///etc/hosts` are correctly parsed as `/etc/hosts`.
(cherry picked from commit cae9d9d20f)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-120423: `pathname2url()`: handle forward slashes in Windows paths (GH-126593)
Adjust `urllib.request.pathname2url()` so that forward slashes in Windows
paths are handled identically to backward slashes.
(cherry picked from commit bf224bd7ce)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
GH-126212: Fix removal of slashes in file URIs on Windows (GH-126214)
Adjust `urllib.request.pathname2url()` and `url2pathname()` so that they
don't remove slashes from Windows DOS drive paths and URLs. There was no
basis for this behaviour, and it conflicts with how UNC and POSIX paths are
handled.
(cherry picked from commit 54c63a32d0)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
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 951cb2c369)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
who writes:
Here is batch 2, as a big collection of CVS context diffs.
Along with moving comments into docstrings, i've added a
couple of missing docstrings and attempted to make sure more
module docstrings begin with a one-line summary.
I did not add docstrings to the methods in profile.py for
fear of upsetting any careful optimizations there, though
i did move class documentation into class docstrings.
The convention i'm using is to leave credits/version/copyright
type of stuff in # comments, and move the rest of the descriptive
stuff about module usage into module docstrings. Hope this is
okay.
Pathnames of files on other hosts in the same domain
(\\host\path\to\file) are not translated correctly to URLs and back.
The URL should be something like file:////host/path/to/file.
Note that a combination of drive letter and remote host is not
possible.