Repository navigation
fix: detect zstd streams starting with a skippable frame - #1116
Open
Sanjays2402 wants to merge 2 commits into
Open
Sanjays2402 wants to merge 2 commits into
Sanjays2402 wants to merge 2 commits into
Conversation
Collaborator
|
The new test fails on main and passes with the change. pzstd output without an extension now decompresses correctly, and .zst files from pzstd no longer get the “might be misnamed” message. The comment needs two fixes:
the length check is not needed because buf always holds 270 bytes. A slice pattern is shorter and passes the same tests. |
Fix the RFC reference (skippable frames are defined in RFC 8878 section 3.1.2, not 3.1.1.3), note in the comment that an LZ4 stream starting with a skippable frame is detected as zstd here too, and replace the length check with the shorter slice pattern.
Author
|
Thanks, fixed the comment (skippable frames are RFC 8878 section 3.1.2) and switched to the slice pattern. I also noted the LZ4 caveat in the comment, since an LZ4 stream starting with a skippable frame is still detected as zstd here. Detection behavior is unchanged. |
valoq
self-requested a review
November 18, 2026 11:43
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.
Fixes #1115.
try_infer_formatonly recognized a zstd stream starting with the standard frame magic, so a stream starting with a skippable frame (magics0x184D2A50-0x184D2A5F, RFC 8878 section 3.1.1.3) was not detected at all. Without an extension that meant a hard "Cannot decompress files" error, even though the zstd decoder itself handles the file fine (--format zstworked, andfilereports it as Zstandard data).This teaches
is_zstto also accept a leading skippable frame magic, so those streams are detected aszstlike any other.Test: added
try_infer_format_recognizes_zstd_skippable_frame_magic, covering both ends of the skippable range and one magic just outside it. It fails on main and passes with this change. I also verified end to end with a real zstd file prefixed by a skippable frame: it failed to decompress without an extension before, and decompresses fine after. Full suite green:cargo test --profile fast(54 unit, 57 integration, 13 UI, plus mime and format-flag tests), clippy clean,cargo +nightly fmt -- --checkclean.