Commit 2ad5421d authored by Benjamin Peterson's avatar Benjamin Peterson

don't index outside of the path (closes #22312)

parent 3f48d394
...@@ -113,7 +113,7 @@ def splitdrive(p): ...@@ -113,7 +113,7 @@ def splitdrive(p):
""" """
if len(p) > 1: if len(p) > 1:
normp = p.replace(altsep, sep) normp = p.replace(altsep, sep)
if (normp[0:2] == sep*2) and (normp[2] != sep): if (normp[0:2] == sep*2) and (normp[2:3] != sep):
# is a UNC path: # is a UNC path:
# vvvvvvvvvvvvvvvvvvvv drive letter or UNC path # vvvvvvvvvvvvvvvvvvvv drive letter or UNC path
# \\machine\mountpoint\directory\etc\... # \\machine\mountpoint\directory\etc\...
......
...@@ -50,6 +50,7 @@ class TestNtpath(unittest.TestCase): ...@@ -50,6 +50,7 @@ class TestNtpath(unittest.TestCase):
# Issue #19911: UNC part containing U+0130 # Issue #19911: UNC part containing U+0130
self.assertEqual(ntpath.splitdrive(u'//conky/MOUNTPOİNT/foo/bar'), self.assertEqual(ntpath.splitdrive(u'//conky/MOUNTPOİNT/foo/bar'),
(u'//conky/MOUNTPOİNT', '/foo/bar')) (u'//conky/MOUNTPOİNT', '/foo/bar'))
self.assertEqual(ntpath.splitdrive("//"), ("", "//"))
def test_splitunc(self): def test_splitunc(self):
tester('ntpath.splitunc("c:\\foo\\bar")', tester('ntpath.splitunc("c:\\foo\\bar")',
......
...@@ -19,6 +19,8 @@ Core and Builtins ...@@ -19,6 +19,8 @@ Core and Builtins
Library Library
------- -------
- Issue #22312: Fix ntpath.splitdrive IndexError.
- Issue #22216: smtplib now resets its state more completely after a quit. The - Issue #22216: smtplib now resets its state more completely after a quit. The
most obvious consequence of the previous behavior was a STARTTLS failure most obvious consequence of the previous behavior was a STARTTLS failure
during a connect/starttls/quit/connect/starttls sequence. during a connect/starttls/quit/connect/starttls sequence.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment