Skip to content

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

Closed
@barneygale

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only security fixes3.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