mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Handle broken Photoshop data
This commit is contained in:
parent
a9fc1b66b1
commit
e51be50549
BIN
Tests/images/photoshop-200dpi-broken.jpg
Normal file
BIN
Tests/images/photoshop-200dpi-broken.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -656,6 +656,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)
|
||||
|
|
|
@ -109,7 +109,10 @@ def APP(self, marker):
|
|||
while blocks[offset : offset + 4] == b"8BIM":
|
||||
offset += 4
|
||||
# resource code
|
||||
code = i16(blocks, offset)
|
||||
try:
|
||||
code = i16(blocks, offset)
|
||||
except struct.error:
|
||||
break
|
||||
offset += 2
|
||||
# resource name (usually empty)
|
||||
name_len = i8(blocks[offset])
|
||||
|
|
Loading…
Reference in New Issue
Block a user