]> granicus.if.org Git - python/commitdiff
Merged revisions 72295 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 May 2009 21:24:37 +0000 (21:24 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 May 2009 21:24:37 +0000 (21:24 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72295 | antoine.pitrou | 2009-05-04 23:17:17 +0200 (lun., 04 mai 2009) | 3 lines

  Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory.
........

Lib/zipfile.py
Misc/NEWS

index fe012968b373f7cd8ee5748ee0e5f6efe8e5b9b3..aa88563e5f1cc60bf6ef6f7ac1c3c70c12326a0c 100644 (file)
@@ -940,7 +940,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 03d318d9299b325db5ed38f1d8ebe844dd5a2180..62f2948f8724de94f2401154b4f3e3e3a25f6179 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -36,6 +36,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when
+  extracting a file to the root directory.
+
 - Issue #2245: aifc now skips chunk types it doesn't recognize, per spec.
 
 - Issue #4305: ctypes should now build again on mipsel-linux-gnu