From: Antoine Pitrou Date: Mon, 4 May 2009 21:17:17 +0000 (+0000) Subject: Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting... X-Git-Tag: v2.7a1~1287 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97377bf56685282ac6e504f64e71794a7bdd80b6;p=python Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory. --- diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 31063535c8..a1e44c0837 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -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 diff --git a/Misc/NEWS b/Misc/NEWS index 587106c045..c8ae918405 100644 --- 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,