Skip to content

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

Merged
JimBobSquarePants merged 2 commits into
release/3.1.xfrom
js/v3-issue-2925
May 30, 2025
Merged

V3 - Do not throw exception for non-required chunks.#2929
JimBobSquarePants merged 2 commits into
release/3.1.xfrom
js/v3-issue-2925

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

FileDescription
tests/Images/Input/Webp/issues/Issue2925.webpAdded test fixture for Issue 2925
tests/ImageSharp.Tests/TestImages.csRegistered Issue2925 constant
tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.csAdded WebpDecoder_CanDecode_Issue2925 test
src/ImageSharp/Formats/Webp/WebpDecoderCore.csMade 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.");

Comment threadsrc/ImageSharp/Formats/Webp/WebpDecoderCore.cs
Comment threadsrc/ImageSharp/Formats/Webp/WebpDecoderCore.cs
@JimBobSquarePants
JimBobSquarePants merged commit a7d6de9 into release/3.1.xMay 30, 2025
@JimBobSquarePants
JimBobSquarePants deleted the js/v3-issue-2925 branch May 30, 2025 00:19
Sign up for freeto 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.

2 participants

@JimBobSquarePants