Skip to content

fix(Zip): Improve parsing of non-standard ZIP archives#5107

Merged
matejk merged 1 commit intomainfrom
4651-zip-parsing-fixes
Dec 18, 2025
Merged

fix(Zip): Improve parsing of non-standard ZIP archives#5107
matejk merged 1 commit intomainfrom
4651-zip-parsing-fixes

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented Dec 17, 2025

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-N suffix to preserve all data:

file.txt
file.txt.duplicate-1
file.txt.duplicate-2

2. Extended CompressionMethod enum

Added support for recognizing additional compression methods defined in the ZIP specification:

  • CM_BZIP2 (12)
  • CM_LZMA (14)
  • CM_ZSTD (93)
  • CM_XZ (95)
  • CM_PPMD (98)
  • CM_AES (99)
  • And others

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

@matejk matejk merged commit 1ed9388 into main Dec 18, 2025
86 checks passed
@matejk matejk deleted the 4651-zip-parsing-fixes branch December 18, 2025 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorporate wdx_ziptype changes (fix for Poco::Zlib: Unexpected exceptions and others)

1 participant