Skip to content

Commit

Permalink
Merge pull request #2245 from SixLabors/bp/Issue2243
Browse files Browse the repository at this point in the history
Webp: Ignore unknown chunks, fixes #2243
  • Loading branch information
JimBobSquarePants authored Sep 28, 2022
2 parents e7f701e + 770a850 commit 38348f2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ImageSharp/Formats/Webp/WebpDecoderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ private WebpImageInfo ReadVp8Info(bool ignoreAlpha = false)
}
else
{
WebpThrowHelper.ThrowImageFormatException("Unexpected chunk followed VP8X header");
// Ignore unknown chunks.
uint chunkSize = this.ReadChunkSize();
this.currentStream.Skip((int)chunkSize);
}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ public void WebpDecoder_CanDecode_Issue1594<TPixel>(TestImageProvider<TPixel> pr
image.CompareToOriginal(provider, ReferenceDecoder);
}

// https://github.com/SixLabors/ImageSharp/issues/2243
[Theory]
[WithFile(Lossy.Issue2243, PixelTypes.Rgba32)]
public void WebpDecoder_CanDecode_Issue2243<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using Image<TPixel> image = provider.GetImage(WebpDecoder);
image.DebugSave(provider);
image.CompareToOriginal(provider, ReferenceDecoder);
}

[Theory]
[WithFile(Lossless.LossLessCorruptImage3, PixelTypes.Rgba32)]
public void WebpDecoder_ThrowImageFormatException_OnInvalidImages<TPixel>(TestImageProvider<TPixel> provider)
Expand Down
1 change: 1 addition & 0 deletions tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ public static class Lossy

// Issues
public const string Issue1594 = "Webp/issues/Issue1594.webp";
public const string Issue2243 = "Webp/issues/Issue2243.webp";
}
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Images/Input/Webp/issues/Issue2243.webp
Git LFS file not shown

0 comments on commit 38348f2

Please sign in to comment.