summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-02-20 08:40:38 (GMT)
committerGeorg Brandl <georg@python.org>2006-02-20 08:40:38 (GMT)
commit8f7c54eaa5e363ef02e99518253b3cb17f6602e6 (patch)
tree80de626902f35cd4d90f271c4641b020b256f4f6 /Lib/zipfile.py
parent200a58058a504da4cc2f9145e671b009b0bedd27 (diff)
downloadcpython-8f7c54eaa5e363ef02e99518253b3cb17f6602e6.zip
cpython-8f7c54eaa5e363ef02e99518253b3cb17f6602e6.tar.gz
cpython-8f7c54eaa5e363ef02e99518253b3cb17f6602e6.tar.bz2
Bug #1413790: zipfile now sanitizes absolute archive names that are
not allowed by the specs.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 037843c..168d245 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -397,9 +397,11 @@ class ZipFile:
date_time = mtime[0:6]
# Create ZipInfo instance to store file information
if arcname is None:
- zinfo = ZipInfo(filename, date_time)
- else:
- zinfo = ZipInfo(arcname, date_time)
+ arcname = filename
+ arcname = os.path.normpath(os.path.splitdrive(arcname)[1])
+ while arcname[0] in (os.sep, os.altsep):
+ arcname = arcname[1:]
+ zinfo = ZipInfo(arcname, date_time)
zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes
if compress_type is None:
zinfo.compress_type = self.compression