mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-29 18:54:16 +03:00
handle Photoshop chunks which can't be processed
This commit is contained in:
parent
3841c96ec6
commit
f55eb73934
|
@ -101,16 +101,16 @@ def APP(self, marker):
|
||||||
# markers appear in the correct sequence.
|
# markers appear in the correct sequence.
|
||||||
self.icclist.append(s)
|
self.icclist.append(s)
|
||||||
elif marker == 0xFFED and s[:14] == b"Photoshop 3.0\x00":
|
elif marker == 0xFFED and s[:14] == b"Photoshop 3.0\x00":
|
||||||
|
# Process this marker only if previous were empty
|
||||||
|
if not self.info.get("photoshop"):
|
||||||
# parse the image resource block
|
# parse the image resource block
|
||||||
offset = 14
|
offset = 14
|
||||||
photoshop = {}
|
photoshop = {}
|
||||||
while s[offset : offset + 4] == b"8BIM":
|
while s[offset : offset + 4] == b"8BIM":
|
||||||
|
try:
|
||||||
offset += 4
|
offset += 4
|
||||||
# resource code
|
# resource code
|
||||||
try:
|
|
||||||
code = i16(s, offset)
|
code = i16(s, offset)
|
||||||
except struct.error:
|
|
||||||
break
|
|
||||||
offset += 2
|
offset += 2
|
||||||
# resource name (usually empty)
|
# resource name (usually empty)
|
||||||
name_len = i8(s[offset])
|
name_len = i8(s[offset])
|
||||||
|
@ -131,6 +131,8 @@ def APP(self, marker):
|
||||||
photoshop[code] = data
|
photoshop[code] = data
|
||||||
offset += size
|
offset += size
|
||||||
offset += offset & 1 # align
|
offset += offset & 1 # align
|
||||||
|
except struct.error:
|
||||||
|
break # no sufficient data
|
||||||
self.info["photoshop"] = photoshop
|
self.info["photoshop"] = photoshop
|
||||||
|
|
||||||
elif marker == 0xFFEE and s[:5] == b"Adobe":
|
elif marker == 0xFFEE and s[:5] == b"Adobe":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user