Skip to content

Commit 2c3967b

Browse files
Merge pull request #2505 from sonbua/backport/2243
V2 backport: 2243 - Ignore unknown chunks for WEBP
2 parents 168f3f5 + 62b65d7 commit 2c3967b

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

src/ImageSharp/Formats/Webp/WebpDecoderCore.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ private WebpImageInfo ReadVp8XHeader()
277277
}
278278
else
279279
{
280-
WebpThrowHelper.ThrowImageFormatException("Unexpected chunk followed VP8X header");
280+
// Ignore unknown chunks.
281+
uint chunkSize = this.ReadChunkSize();
282+
this.currentStream.Skip((int)chunkSize);
281283
}
282284
}
283285

tests/ImageSharp.Tests/Formats/WebP/WebpDecoderTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,17 @@ public void WebpDecoder_CanDecode_Issue1594<TPixel>(TestImageProvider<TPixel> pr
358358
}
359359
}
360360

361+
// https://github.com/SixLabors/ImageSharp/issues/2243
362+
[Theory]
363+
[WithFile(Lossy.Issue2243, PixelTypes.Rgba32)]
364+
public void WebpDecoder_CanDecode_Issue2243<TPixel>(TestImageProvider<TPixel> provider)
365+
where TPixel : unmanaged, IPixel<TPixel>
366+
{
367+
using Image<TPixel> image = provider.GetImage(WebpDecoder);
368+
image.DebugSave(provider);
369+
image.CompareToOriginal(provider, ReferenceDecoder);
370+
}
371+
361372
[Theory]
362373
[WithFile(Lossless.LossLessCorruptImage3, PixelTypes.Rgba32)]
363374
public void WebpDecoder_ThrowImageFormatException_OnInvalidImages<TPixel>(TestImageProvider<TPixel> provider)

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ public static class Lossy
741741

742742
// Issues
743743
public const string Issue1594 = "Webp/issues/Issue1594.webp";
744+
public const string Issue2243 = "Webp/issues/Issue2243.webp";
744745
}
745746
}
746747

Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)