@@ -255,7 +255,7 @@ public void Identify(string imagePath, int expectedPixelSize)
255255 public void Decode_MissingDataChunk_ThrowsException < TPixel > ( TestImageProvider < TPixel > provider )
256256 where TPixel : unmanaged, IPixel < TPixel >
257257 {
258- System . Exception ex = Record . Exception (
258+ Exception ex = Record . Exception (
259259 ( ) =>
260260 {
261261 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -271,7 +271,7 @@ public void Decode_MissingDataChunk_ThrowsException<TPixel>(TestImageProvider<TP
271271 public void Decode_InvalidBitDepth_ThrowsException < TPixel > ( TestImageProvider < TPixel > provider )
272272 where TPixel : unmanaged, IPixel < TPixel >
273273 {
274- System . Exception ex = Record . Exception (
274+ Exception ex = Record . Exception (
275275 ( ) =>
276276 {
277277 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -287,7 +287,7 @@ public void Decode_InvalidBitDepth_ThrowsException<TPixel>(TestImageProvider<TPi
287287 public void Decode_InvalidColorType_ThrowsException < TPixel > ( TestImageProvider < TPixel > provider )
288288 where TPixel : unmanaged, IPixel < TPixel >
289289 {
290- System . Exception ex = Record . Exception (
290+ Exception ex = Record . Exception (
291291 ( ) =>
292292 {
293293 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -297,13 +297,27 @@ public void Decode_InvalidColorType_ThrowsException<TPixel>(TestImageProvider<TP
297297 Assert . Contains ( "Invalid or unsupported color type" , ex . Message ) ;
298298 }
299299
300+ [ Theory ]
301+ [ WithFile ( TestImages . Png . Bad . WrongCrcDataChunk , PixelTypes . Rgba32 ) ]
302+ public void Decode_InvalidDataChunkCrc_ThrowsException < TPixel > ( TestImageProvider < TPixel > provider )
303+ where TPixel : unmanaged, IPixel < TPixel >
304+ {
305+ InvalidImageContentException ex = Assert . Throws < InvalidImageContentException > (
306+ ( ) =>
307+ {
308+ using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
309+ } ) ;
310+ Assert . NotNull ( ex ) ;
311+ Assert . Contains ( "CRC Error. PNG IDAT chunk is corrupt!" , ex . Message ) ;
312+ }
313+
300314 // https://github.com/SixLabors/ImageSharp/issues/1014
301315 [ Theory ]
302316 [ WithFileCollection ( nameof ( TestImagesIssue1014 ) , PixelTypes . Rgba32 ) ]
303317 public void Issue1014_DataSplitOverMultipleIDatChunks < TPixel > ( TestImageProvider < TPixel > provider )
304318 where TPixel : unmanaged, IPixel < TPixel >
305319 {
306- System . Exception ex = Record . Exception (
320+ Exception ex = Record . Exception (
307321 ( ) =>
308322 {
309323 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -319,7 +333,7 @@ public void Issue1014_DataSplitOverMultipleIDatChunks<TPixel>(TestImageProvider<
319333 public void Issue1177_CRC_Omitted < TPixel > ( TestImageProvider < TPixel > provider )
320334 where TPixel : unmanaged, IPixel < TPixel >
321335 {
322- System . Exception ex = Record . Exception (
336+ Exception ex = Record . Exception (
323337 ( ) =>
324338 {
325339 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -335,7 +349,7 @@ public void Issue1177_CRC_Omitted<TPixel>(TestImageProvider<TPixel> provider)
335349 public void Issue1127 < TPixel > ( TestImageProvider < TPixel > provider )
336350 where TPixel : unmanaged, IPixel < TPixel >
337351 {
338- System . Exception ex = Record . Exception (
352+ Exception ex = Record . Exception (
339353 ( ) =>
340354 {
341355 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -351,7 +365,7 @@ public void Issue1127<TPixel>(TestImageProvider<TPixel> provider)
351365 public void Issue1047 < TPixel > ( TestImageProvider < TPixel > provider )
352366 where TPixel : unmanaged, IPixel < TPixel >
353367 {
354- System . Exception ex = Record . Exception (
368+ Exception ex = Record . Exception (
355369 ( ) =>
356370 {
357371 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -372,7 +386,7 @@ public void Issue1047<TPixel>(TestImageProvider<TPixel> provider)
372386 public void Issue1765 < TPixel > ( TestImageProvider < TPixel > provider )
373387 where TPixel : unmanaged, IPixel < TPixel >
374388 {
375- System . Exception ex = Record . Exception (
389+ Exception ex = Record . Exception (
376390 ( ) =>
377391 {
378392 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
@@ -388,7 +402,7 @@ public void Issue1765<TPixel>(TestImageProvider<TPixel> provider)
388402 public void Issue410_MalformedApplePng < TPixel > ( TestImageProvider < TPixel > provider )
389403 where TPixel : unmanaged, IPixel < TPixel >
390404 {
391- System . Exception ex = Record . Exception (
405+ Exception ex = Record . Exception (
392406 ( ) =>
393407 {
394408 using Image < TPixel > image = provider . GetImage ( PngDecoder ) ;
0 commit comments