Skip to content

bpo-37538: Zipfile refactor #14957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 29 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a0db1c9
Add descriptive global variables for general purpose bit flags
danifus Jul 10, 2019
6710baf
Add global variable for zip64 extra data header id
danifus Jul 10, 2019
3777389
Add flag properties to ZipInfo
danifus Jul 10, 2019
f435f08
Restructure how ZipExtFile gets created from ZipFile.open
danifus Jul 10, 2019
ca41137
Fix bug when seeking on encrypted zip files
danifus Jul 10, 2019
00c87ee
Refactor _ZipDecrypter with a BaseZipDecrypter class
danifus Jul 11, 2019
b8364a6
Move compressor and decompressor selection code into classes
danifus Jul 12, 2019
6b256c0
Add zipinfo_cls, zipextfile_cls and zipwritefile_cls to ZipFile
danifus Jul 12, 2019
af8864b
Fix typo datadescripter -> datadescriptor
danifus Jul 13, 2019
42c4be6
Add dosdate and dostime properties to ZipInfo
danifus Jul 13, 2019
801d966
Move encoding datadescriptor to ZipInfo
danifus Jul 13, 2019
46604e0
Refactor how ZipInfo encodes the local file header.
danifus Jul 13, 2019
7d28d8f
Move central directory encoding to ZipInfo
danifus Jul 14, 2019
c784d7f
Move struct packing of central directory record to a ZipInfo method
danifus Jul 14, 2019
f84e481
Refactor _decodeExtra to allow subclasses to support new extra fields
danifus Jul 14, 2019
1a07518
Change the way zipfile _decodeExtra loops through the extra bytes
danifus Jul 14, 2019
6de1a9a
Decouple updating and checking crc when reading a zipfile
danifus Jul 14, 2019
6b90dfd
Move writing zipfile local header to _ZipWriteFile
danifus Jul 14, 2019
4417cc5
Move writing local header to within _ZipWriteFile
danifus Jul 15, 2019
bfa8a7e
Add some comments to zipfile's LZMACompressor
danifus Jul 15, 2019
a211abe
Add comments to ZipFile._write_end_record describing structs
danifus Jul 17, 2019
3eff8be
Small performance fix to zipfile.CRCZipDecrypter
danifus Jul 22, 2019
7220ef9
Refactor ZipFile encoding approach
danifus Jul 22, 2019
0a718f7
Change ZipInfo encoding of local extra data
danifus Jul 22, 2019
cb826d6
Allow ZipFile _open_to_write() and _open_to_read() to take kwargs
danifus Jul 26, 2019
5a88b2d
Change ZipFile._open_to_write() to accept pwd argument.
danifus Jul 26, 2019
fa374ee
ZipFile remove special case path for ZIP_STORED
danifus Jul 26, 2019
5bb4c17
📜🤖 Added by blurb_it.
blurb-it[bot] Jul 26, 2019
366f79f
bpo-37538: Small clean up of zipfile refactor
danifus Jul 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change ZipInfo encoding of local extra data
A previous change in the zipfile refactor changeset defaulted the extra
data to be encoded in the local file header to be empty bytes.  This was
because different content may appear in the local file extra data
compared to the central directory extra data (different zip64 fields for
instance).

If opening a file from a ZipInfo instance, the extra data is initialised
with data read from the central directory.

On reflection, the zip64 difference is the only difference between the
two encodings I know of and we can account for that by stripping and
rewritting the zip64 content.

Prior to this changeset the zip64 section was not stripped in the local
file header which may have led to multiple zip64 sections appearing in
files written after being opened with a ZipInfo instance which had zip64
data in its extra data.
  • Loading branch information
danifus committed Jul 26, 2019
commit 0a718f7a644f50500c8bcc8a75922b5cf4a20518
4 changes: 3 additions & 1 deletion Lib/zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,16 @@ def get_local_header_params(self, zip64=False):
compress_size = self.compress_size
file_size = self.file_size

extra = _strip_extra(self.extra, (EXTRA_ZIP64,))
# There are reports that windows 7 can only read zip 64 archives if the
# zip 64 extra block is the first extra block present.
min_version = 0
(extra,
(zip64_extra,
file_size,
compress_size,
zip64_min_version,
) = self.zip64_local_header(zip64, file_size, compress_size)
extra = zip64_extra + extra
min_version = min(min_version, zip64_min_version)

if self.compress_type == ZIP_BZIP2:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy