barneygale · GitHub

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

Read the original on github.com ↗