diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-05-04 21:17:17 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-05-04 21:17:17 (GMT) |
commit | 97377bf56685282ac6e504f64e71794a7bdd80b6 (patch) | |
tree | 7a5133bb252729f87c872bde91d69171e1218884 /Lib | |
parent | e3a3726b3d647a4d20671f6029c05a404af83c56 (diff) | |
download | cpython-97377bf56685282ac6e504f64e71794a7bdd80b6.zip cpython-97377bf56685282ac6e504f64e71794a7bdd80b6.tar.gz cpython-97377bf56685282ac6e504f64e71794a7bdd80b6.tar.bz2 |
Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/zipfile.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 3106353..a1e44c0 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 |