fix(Zip): Improve parsing of non-standard ZIP archives#5107
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves Poco::Zip handling of non-standard ZIP archives that previously caused exceptions during parsing.
Changes
1. Handle duplicate entries
Archives containing duplicate file entries no longer throw assertions. Instead, duplicate entries are renamed with a
.duplicate-Nsuffix to preserve all data:2. Extended CompressionMethod enum
Added support for recognizing additional compression methods defined in the ZIP specification:
Note: These methods are recognized during parsing but decompression still only supports CM_STORE and CM_DEFLATE. Attempting to decompress unsupported methods throws a descriptive exception with the method ID and filename.
3. Removed compression method assertion during parsing
Previously,
poco_assert (... < ZipCommon::CM_UNUSED)prevented parsing archives with compression methods > 10. This assertion is removed; validation now happens at decompression time with a clear error message.4. Fixed data descriptor detection
searchCRCAndSizesAfterData()now checks bit 3 of general purpose flags for all compression methods, not just CM_STORE and CM_DEFLATE.Testing
All 25 Zip tests pass.
Closes #4651