Skip to content

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

Closed

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 20, 2024
  2. barneygale commented on Nov 20, 2024

    @barneygale
    ContributorAuthor

    I think we should wait for #126367 to be fixed before tackling this bug

  3. barneygale commented on Nov 22, 2024

    @barneygale
    ContributorAuthor

    I think we should wait for #126367 to be fixed before tackling this bug

    On second thought, it's better to solve this issue first to avoid backport conflicts.

  4. added 2 commits that reference this issue on Nov 22, 2024
  5. added 2 commits that reference this issue on Nov 22, 2024
  6. added 2 commits that reference this issue on Nov 22, 2024
  7. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13only security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions