Qualify reference to LOAD_TRUNCATED_IMAGES

Setting ImageFile.LOAD_TRUNCATED_IMAGES = True had no effect in loading JPEG images with "extra" data after the end of image marker in a Zope application. Tracing the code showed that although ImageFile.LOAD_TRUNCATED_IMAGES was True, the unqualified reference in ImageFile.py to LOAD_TRUNCATED_IMAGES returned False, and so the load failed.
This commit is contained in:
Hugh Ranalli 2018-11-29 14:13:27 -05:00 committed by GitHub
parent 080bfd3ee1
commit 5676c862be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,13 +221,13 @@ class ImageFile(Image.Image):
s = read(self.decodermaxblock)
except (IndexError, struct.error):
# truncated png/gif
if LOAD_TRUNCATED_IMAGES:
if ImageFile.LOAD_TRUNCATED_IMAGES:
break
else:
raise IOError("image file is truncated")
if not s: # truncated jpeg
if LOAD_TRUNCATED_IMAGES:
if ImageFile.LOAD_TRUNCATED_IMAGES:
break
else:
self.tile = []