Skip to content

ntpath.join() adds slash to incomplete UNC drive with trailing slash #103220

Description

@barneygale

ntpath.join() incorrectly inserts an additional slash when joining an argument onto an incomplete UNC drive with a trailing slash:

>>> import ntpath
>>> ntpath.join('\\\\server\\share\\foo\\', 'bar')
'\\\\server\\share\\foo\\bar'  # ok
>>> ntpath.join('\\\\server\\share\\', 'foo')
'\\\\server\\share\\foo'  # ok
>>> ntpath.join('\\\\server\\', 'share')
'\\\\server\\\\share'  # wrong!
>>> ntpath.join('\\\\', 'server')
'\\\\\\server'  # wrong!

Before 005e694 (3.12), the last test case succeeds because splitdrive() doesn't identify '\\\\' as a UNC drive. But the third test case is reproducible going back to 3.11 and 3.10.

Linked PRs

Activity

  1. added a commit that references this issue on Apr 3, 2023
  2. eryksun commented on Apr 3, 2023

    @eryksun
    Contributor

    This would be an enhancement to add the ability to reliably join segments as a UNC drive. I don't think it has to be backported to 3.11 and 3.10.

  3. added a commit that references this issue on Apr 11, 2023
  4. barneygale commented on Apr 11, 2023

    @barneygale
    ContributorAuthor

    Resolved in b57105a / #103221.

  5. added a commit that references this issue on Apr 11, 2023
  6. added a commit that references this issue on Apr 18, 2023
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.10 (EOL)end of life3.11only security fixes3.12only security fixesOS-windowstype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions