Merge pull request #4239 from radarhere/photoshop

Handle broken Photoshop data
This commit is contained in:
Andrew Murray 2019-12-01 07:33:26 +11:00 committed by GitHub
commit 2d7cfc4bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -659,6 +659,11 @@ class TestFileJpeg(PillowTestCase):
},
)
# Test that the image can still load, even with broken Photoshop data
# This image had the APP13 length hexedited to be smaller
with Image.open("Tests/images/photoshop-200dpi-broken.jpg") as im_broken:
self.assert_image_equal(im_broken, im)
# This image does not contain a Photoshop header string
with Image.open("Tests/images/app13.jpg") as im:
self.assertNotIn("photoshop", im.info)

View File

@ -109,7 +109,10 @@ def APP(self, marker):
while blocks[offset : offset + 4] == b"8BIM":
offset += 4
# resource code
try:
code = i16(blocks, offset)
except struct.error:
break
offset += 2
# resource name (usually empty)
name_len = i8(blocks[offset])