Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
barneygale opened this issue Apr 3, 2023 · 2 comments
Closed
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes OS-windows type-bug An unexpected behavior, bug, or error

Comments

@barneygale
Copy link
Contributor

barneygale commented Apr 3, 2023

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

@barneygale barneygale added type-bug An unexpected behavior, bug, or error OS-windows 3.11 only security fixes 3.10 only security fixes 3.12 bugs and security fixes labels Apr 3, 2023
barneygale added a commit to barneygale/cpython that referenced this issue Apr 3, 2023
@eryksun
Copy link
Contributor

eryksun commented Apr 3, 2023

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.

@barneygale
Copy link
Contributor Author

Resolved in b57105a / #103221.

warsaw pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
aisk pushed a commit to aisk/cpython that referenced this issue Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.10 only security fixes 3.11 only security fixes 3.12 bugs and security fixes OS-windows type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants