Skip to content

V3 - Do not throw exception for non-required chunks. #2929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #2925

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ReadChunkSize to accept a required flag 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.");

@JimBobSquarePants JimBobSquarePants merged commit a7d6de9 into release/3.1.x May 30, 2025
8 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/v3-issue-2925 branch May 30, 2025 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant