mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #4239 from radarhere/photoshop
Handle broken Photoshop data
This commit is contained in:
commit
2d7cfc4bbc
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 |
|
@ -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
|
# This image does not contain a Photoshop header string
|
||||||
with Image.open("Tests/images/app13.jpg") as im:
|
with Image.open("Tests/images/app13.jpg") as im:
|
||||||
self.assertNotIn("photoshop", im.info)
|
self.assertNotIn("photoshop", im.info)
|
||||||
|
|
|
@ -109,7 +109,10 @@ def APP(self, marker):
|
||||||
while blocks[offset : offset + 4] == b"8BIM":
|
while blocks[offset : offset + 4] == b"8BIM":
|
||||||
offset += 4
|
offset += 4
|
||||||
# resource code
|
# resource code
|
||||||
code = i16(blocks, offset)
|
try:
|
||||||
|
code = i16(blocks, offset)
|
||||||
|
except struct.error:
|
||||||
|
break
|
||||||
offset += 2
|
offset += 2
|
||||||
# resource name (usually empty)
|
# resource name (usually empty)
|
||||||
name_len = i8(blocks[offset])
|
name_len = i8(blocks[offset])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user