Repository navigation
fix: by_name().get_metadata() and by_index().get_metadata() now succeed even when compression method is unsupported - #1228
Conversation
There was a problem hiding this comment.
The changes in this PR correctly address the stated goal of allowing by_name(), by_index(), and by_name_raw() to succeed (returning a ZipFile with accessible metadata) when the archive contains an entry with an unsupported compression method.
Summary of changes:
src/read/readers.rs: Removes the early-return guard inmake_crypto_readerthat rejected unsupported compression methods before any crypto setup. SinceLazyDecompressoris lazy,make_readernow succeeds and the error surfaces only on the firstread()call — this is the intended behavior change.src/read/zip_archive.rs: Adds the newby_name_rawpublic API method, which delegates toby_index_rawto return the raw compressed bytes without decompression.tests/unsupported_compression_metadata.rs: New integration test that constructs a valid ZIP, patches the compression method field to an unsupported value (222) in both local and central directory headers at the correct offsets per the ZIP spec (LFH+8, CDFH+10), and asserts thatget_metadata()succeeds.
The ZIP field offsets used for patching in the test are correct per the APPNOTE specification. No blocking defects found. The test does not exercise the read-failure path (attempting to decompress with method 222), but that is not the advertised behavior being fixed.
One observation: The test file uses SimpleFileOptions::default() which in a default-features build will apply Deflate compression before the bytes are patched, meaning compressed_size could be either larger or smaller than the plaintext b"content" (7 bytes). The assertion compressed_size > 0 is safe regardless. ✅
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
zip 9.2.0 (zip-rs/zip2#1228) stopped returning CompressionMethodNotSupported from by_index and read_zipfile_from_stream; the refusal surfaces on the first read as io::ErrorKind::Unsupported, which the payload fold turns into exit 5. A reduce entry, a zstd entry on the pure tier, or shrink/implode from a pipe would read as corrupt. refuse_undecodable_method restores the open-time refusal (exit 3) on both rungs for any method zip parses as CompressionMethod::Unsupported. A no-op on zip 9.1.3, which refused first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Need help on this PR? Tag
@codesmith-botwith what you need.