]> granicus.if.org Git - python/commitdiff
Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting...
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 May 2009 21:17:17 +0000 (21:17 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 May 2009 21:17:17 +0000 (21:17 +0000)
Lib/zipfile.py
Misc/NEWS

index 31063535c8db1ed4bfa97abfb86ec344ce5c3f26..a1e44c08372eaca7f7846e8afeb23ce5e6f75a94 100644 (file)
@@ -952,7 +952,9 @@ class ZipFile:
         """
         # build the destination pathname, replacing
         # forward slashes to platform specific separators.
-        if targetpath[-1:] in (os.path.sep, os.path.altsep):
+        # Strip trailing path separator, unless it represents the root.
+        if (targetpath[-1:] in (os.path.sep, os.path.altsep)
+            and len(os.path.splitdrive(targetpath)[1]) > 1):
             targetpath = targetpath[:-1]
 
         # don't include leading "/" from file name if present
index 587106c045ef73b77afd524238b8e5c1c2d74868..c8ae918405066c7c5ac0318d2b4df14772f45fc1 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -269,6 +269,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when
+  extracting a file to the root directory.
+
 - Issue #5913: os.listdir() should fail for empty path on windows.
 
 - Issue #5084: unpickling now interns the attribute names of pickled objects,