Skip to content

Detect ZIP archives as binary content#3686

Merged
keith-hall merged 2 commits intosharkdp:masterfrom
officialasishkumar:fix-zip-binary-detection
Apr 10, 2026
Merged

Detect ZIP archives as binary content#3686
keith-hall merged 2 commits intosharkdp:masterfrom
officialasishkumar:fix-zip-binary-detection

Conversation

@officialasishkumar
Copy link
Copy Markdown
Contributor

Summary

  • keep the existing content_inspector path and add a narrow ZIP magic fallback when it would otherwise classify archive bytes as UTF-8 text
  • treat the standard ZIP signatures (PK\x03\x04, PK\x05\x06, PK\x07\x08) as binary content
  • add unit and integration regressions covering ZIP detection without changing other PK-prefixed text

Testing

  • cargo test --lib
  • cargo test --test integration_tests

Closes #3663

Copy link
Copy Markdown
Collaborator

@keith-hall keith-hall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@keith-hall keith-hall merged commit a995764 into sharkdp:master Apr 10, 2026
24 checks passed
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.

Bat tries to read .zip files as text

2 participants