Merge pull request #3532 from radarhere/png_load_end_idat

PNG: Handle IDAT chunks after image end
This commit is contained in:
Hugo van Kemenade 2019-01-05 12:08:58 +02:00 committed by GitHub
commit 22b0f53eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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