Handle IDAT chunks after image end

This commit is contained in:
Andrew Murray 2019-01-03 19:13:19 +11:00
parent 41fba67fb0
commit ea2a0e4654
3 changed files with 6 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -585,6 +585,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

@ -677,6 +677,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