]> granicus.if.org Git - python/commitdiff
Merged revisions 72295 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 May 2009 21:21:36 +0000 (21:21 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 4 May 2009 21:21:36 +0000 (21:21 +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 a54a354d0ce9bb4a44a9e753dff132a53f46eaa0..dab595bb7a487833ee1321b38f9dc609c5f493c0 100644 (file)
@@ -959,7 +959,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 378ed327497e9512623ecfb28647f1027ad6c5df..a92164b9d7137add5f0953c222b1fead625a2c41 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -112,6 +112,9 @@ Installation
 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,