]> granicus.if.org Git - python/commitdiff
don't index outside of the path (closes #22312)
authorBenjamin Peterson <benjamin@python.org>
Sun, 31 Aug 2014 13:34:09 +0000 (09:34 -0400)
committerBenjamin Peterson <benjamin@python.org>
Sun, 31 Aug 2014 13:34:09 +0000 (09:34 -0400)
Lib/ntpath.py
Lib/test/test_ntpath.py
Misc/NEWS

index 228bbb3f52f7a6ae43b12b788e171797e02a52c5..fcaf21b6b7830d521581d207129b1f24f5689a99 100644 (file)
@@ -113,7 +113,7 @@ def splitdrive(p):
     """
     if len(p) > 1:
         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:
             # vvvvvvvvvvvvvvvvvvvv drive letter or UNC path
             # \\machine\mountpoint\directory\etc\...
index 78af18c62193923f66eea63012c823bcbefe419f..7b5f7bb28c33a249b9e6e5850ecf42baaa1a96e8 100644 (file)
@@ -50,6 +50,7 @@ class TestNtpath(unittest.TestCase):
         # Issue #19911: UNC part containing U+0130
         self.assertEqual(ntpath.splitdrive(u'//conky/MOUNTPOİNT/foo/bar'),
                          (u'//conky/MOUNTPOİNT', '/foo/bar'))
+        self.assertEqual(ntpath.splitdrive("//"), ("", "//"))
 
     def test_splitunc(self):
         tester('ntpath.splitunc("c:\\foo\\bar")',
index 5d800347f48454c25cf67cce1480390551a42ce6..d139e7b9d6ef03c687a04bdf25720035752fe8b8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #22312: Fix ntpath.splitdrive IndexError.
+
 - Issue #22216: smtplib now resets its state more completely after a quit.  The
   most obvious consequence of the previous behavior was a STARTTLS failure
   during a connect/starttls/quit/connect/starttls sequence.