summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorSilas Sewell <silas@sewell.org>2018-09-18 17:00:05 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2018-09-18 17:00:05 (GMT)
commit4ba3b50bfe6d50cd82d208023ea23e203ab50589 (patch)
treee6b460ddc7de1ef0268f7717943f41556c488314 /Lib/zipfile.py
parentd0f49d2f5085ca68e3dc8725f1fb1c9674bfb5ed (diff)
downloadcpython-4ba3b50bfe6d50cd82d208023ea23e203ab50589.zip
cpython-4ba3b50bfe6d50cd82d208023ea23e203ab50589.tar.gz
cpython-4ba3b50bfe6d50cd82d208023ea23e203ab50589.tar.bz2
bpo-34472: Add data descriptor signature to zipfile (GH-8871)
This makes streamed zips compatible with MacOS Archive Utility and other applications.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 89df90b..4a6b40e 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -159,6 +159,8 @@ _CD64_NUMBER_ENTRIES_TOTAL = 7
_CD64_DIRECTORY_SIZE = 8
_CD64_OFFSET_START_CENTDIR = 9
+_DD_SIGNATURE = 0x08074b50
+
_EXTRA_FIELD_STRUCT = struct.Struct('<HH')
def _strip_extra(extra, xids):
@@ -1118,8 +1120,8 @@ class _ZipWriteFile(io.BufferedIOBase):
# Write updated header info
if self._zinfo.flag_bits & 0x08:
# Write CRC and file sizes after the file data
- fmt = '<LQQ' if self._zip64 else '<LLL'
- self._fileobj.write(struct.pack(fmt, self._zinfo.CRC,
+ fmt = '<LLQQ' if self._zip64 else '<LLLL'
+ self._fileobj.write(struct.pack(fmt, _DD_SIGNATURE, self._zinfo.CRC,
self._zinfo.compress_size, self._zinfo.file_size))
self._zipfile.start_dir = self._fileobj.tell()
else: