Skip to content

urllib.request.url2pathname() mishandles colons in URLs on Windows #126367

Closed
@barneygale

Description

@barneygale

Bug report

Bug description:

On Windows, urllib.request.url2pathname() has overly simplistic handling of DOS drives in URLs.

Per @eryksun:

>>> from urllib.request import url2pathname
>>> url2pathname('//host/share/spam.txt:eggs')
'T:\\eggs'  # expected: r'\\host\share\spam.txt:eggs'

Also:

>>> url2pathname('///c:/spam.txt:eggs')
OSError: Bad URL: ///c|/spam.txt|eggs  # expected: r'c:\spam.txt:eggs'

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