V3 - Do not throw exception for non-required chunks.#2929
Merged
JimBobSquarePants merged 2 commits intorelease/3.1.xfrom May 30, 2025
Merged
V3 - Do not throw exception for non-required chunks.#2929JimBobSquarePants merged 2 commits intorelease/3.1.xfrom
JimBobSquarePants merged 2 commits intorelease/3.1.xfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that non-required WebP chunks don’t trigger an exception by making chunk-size reads optional and adds a test case for Issue 2925.
- Added a new test image and test to verify decoding of non-required chunks (Issue 2925).
- Updated
ReadChunkSizeto accept arequiredflag and skip unknown chunks without throwing. - Registered the new test image in
TestImages.cs.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/Images/Input/Webp/issues/Issue2925.webp | Added test fixture for Issue 2925 |
| tests/ImageSharp.Tests/TestImages.cs | Registered Issue2925 constant |
| tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs | Added WebpDecoder_CanDecode_Issue2925 test |
| src/ImageSharp/Formats/Webp/WebpDecoderCore.cs | Made ReadChunkSize optional for non-required chunks |
Comments suppressed due to low confidence (1)
src/ImageSharp/Formats/Webp/WebpDecoderCore.cs:516
- [nitpick] The exception message is generic; consider specifying that the failure occurred while reading the chunk size (e.g., "Invalid WebP data: unable to read chunk size.") to improve clarity.
throw new ImageFormatException("Invalid Webp data.");
This was referenced Jul 23, 2025
This was referenced Jul 30, 2025
This was referenced Nov 24, 2025
This was referenced Dec 1, 2025
This was referenced Dec 10, 2025
This was referenced Dec 18, 2025
This was referenced Dec 29, 2025
This was referenced Jan 6, 2026
This was referenced Jan 15, 2026
This was referenced Feb 4, 2026
This was referenced Feb 14, 2026
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.
Prerequisites
Description
Fixes #2925