-
-
Couldn't load subscription status.
- Fork 888
V3: Do not encode WEBP images exceeding max dimensions #2931
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
Conversation
There was a problem hiding this 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 introduces a new strategy to prevent encoding WEBP images whose dimensions exceed a maximum threshold. Key changes include:
- Adding a new exception throwing method in WebpThrowHelper.
- Introducing a dimension check in WebpEncoderCore to preemptively reject oversized images.
- Removing redundant dimension validation in Vp8LEncoder and modifying the JPEG encoder behavior for consistency.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/ImageSharp/Formats/Webp/WebpThrowHelper.cs | Added ThrowDimensionsTooLarge method to report oversized WEBP images. |
| src/ImageSharp/Formats/Webp/WebpEncoderCore.cs | Inserted a check to call the new throw helper for oversized dimensions. |
| src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs | Removed duplicate dimension guard previously present in WriteImageSize. |
| src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs | Updated the dimension check condition to use '>' instead of '>=' for improved consistency. |
Comments suppressed due to low confidence (1)
src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs:374
- The removal of explicit dimension checks in WriteImageSize should be validated to ensure that higher-level checks reliably prevent oversized images across all code paths.
Guard.MustBeLessThan(inputImgWidth, WebpConstants.MaxDimension, nameof(inputImgWidth));
Prerequisites
Description
Fixes #2920