diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-09-22 11:03:04 -0700 |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-09-22 21:03:04 +0300 |
| commit | 44989bc2696320cf55ae6f329aaf58edd49d792a (patch) | |
| tree | 7151eeca2af51b3fae90de93c92d2e364dfb4352 | |
| parent | 0c076caaa82a9c6596e1fe1dbe6384d53f30a1a3 (diff) | |
| download | cpython-git-44989bc2696320cf55ae6f329aaf58edd49d792a.tar.gz | |
bpo-34472: Add data descriptor signature to zipfile (GH-8871) (GH-9399)
This makes streamed zips compatible with MacOS Archive Utility and
other applications.
(cherry picked from commit 4ba3b50bfe6d50cd82d208023ea23e203ab50589)
Co-authored-by: Silas Sewell <silas@sewell.org>
| -rw-r--r-- | Lib/zipfile.py | 6 | ||||
| -rw-r--r-- | Misc/ACKS | 1 | ||||
| -rw-r--r-- | Misc/NEWS.d/next/Library/2018-08-23-09-25-08.bpo-34472.cGyYrO.rst | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 9f88512d98..a43878575d 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): @@ -1114,8 +1116,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: @@ -1456,6 +1456,7 @@ Roger D. Serwy Jerry Seutter Pete Sevander Denis Severson +Silas Sewell Ian Seyer Dmitry Shachnev Anish Shah diff --git a/Misc/NEWS.d/next/Library/2018-08-23-09-25-08.bpo-34472.cGyYrO.rst b/Misc/NEWS.d/next/Library/2018-08-23-09-25-08.bpo-34472.cGyYrO.rst new file mode 100644 index 0000000000..208ec0bf74 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-08-23-09-25-08.bpo-34472.cGyYrO.rst @@ -0,0 +1,3 @@ +Improved compatibility for streamed files in :mod:`zipfile`. Previously an +optional signature was not being written and certain ZIP applications were +not supported. Patch by Silas Sewell. |
