Skip to content

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

Closed
@barneygale

Description

@barneygale

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions