mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Bug #1413790: zipfile now sanitizes absolute archive names that are
not allowed by the specs.
This commit is contained in:
parent
200a58058a
commit
8f7c54eaa5
4 changed files with 26 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue