Handle IDAT chunks after image end

This commit is contained in:
Andrew Murray 2019-01-03 19:13:19 +11:00 committed by Hugo
parent 3fdd7002a9
commit f073be52dc
3 changed files with 6 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -586,6 +586,10 @@ class TestFilePng(PillowTestCase):
self.assertIsInstance(im.text, dict)
ImageFile.LOAD_TRUNCATED_IMAGES = False
# Raises an EOFError in load_end
im = Image.open("Tests/images/hopper_idat_after_image_end.png")
self.assertEqual(im.text, {'TXT': 'VALUE', 'ZIP': 'VALUE'})
@unittest.skipUnless(HAVE_WEBP and _webp.HAVE_WEBPANIM,
"WebP support not installed with animation")
def test_apng(self):

View File

@ -680,6 +680,8 @@ class PngImageFile(ImageFile.ImageFile):
self.png.call(cid, pos, length)
except UnicodeDecodeError:
break
except EOFError:
ImageFile._safe_read(self.fp, length)
self._text = self.png.im_text
self.png.close()
self.png = None