Skip to content

Teach --search-zip to detect compressed files without extensions#3352

Open
krapcys1-maker wants to merge 2 commits intoBurntSushi:masterfrom
krapcys1-maker:fix/issue-3342-20260406-clean
Open

Teach --search-zip to detect compressed files without extensions#3352
krapcys1-maker wants to merge 2 commits intoBurntSushi:masterfrom
krapcys1-maker:fix/issue-3342-20260406-clean

Conversation

@krapcys1-maker
Copy link
Copy Markdown

Fixes #3342

Summary

Teach --search-zip to detect compressed files by file magic when no extension match exists.

Problem

--search-zip currently routes files to decompression commands based on extension globs like *.gz and *.xz. Compressed files without those extensions are skipped even when their contents clearly identify the format.

What changed

  • Extend the decompression matcher to carry optional magic headers for built-in compression formats.
  • Fall back to magic-based detection when no extension glob matches the path.
  • Add a regression test that verifies gzip content is searched correctly even without a .gz extension.

Solution

Keep extension-based matching as the first path, but allow built-in decompression commands to recognize known formats from file headers. That preserves existing behavior for explicit associations while fixing extensionless compressed files.

Why

This fixes the exact gap described in the issue without changing the command-selection surface for custom user associations. --search-zip now behaves according to the file contents instead of requiring a specific suffix.

Tests

  • cargo test --test integration compressed_gzip -- --nocapture
  • cargo check

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.

search-zip should use standardised file detection instead of extension

2 participants