Discard first byte if not 0xFF (for issue #630)

This commit is contained in:
hugovk 2014-05-05 22:09:57 +03:00
parent 73eafbb55f
commit e835dd70a1

View File

@ -290,9 +290,14 @@ class JpegImageFile(ImageFile.ImageFile):
while True:
i = i8(s)
if i == 0xFF:
s = s + self.fp.read(1)
i = i16(s)
else:
# Skip non-0xFF junk
s = "\xff"
continue
if i in MARKER:
name, description, handler = MARKER[i]
@ -307,7 +312,7 @@ class JpegImageFile(ImageFile.ImageFile):
# self.__offset = self.fp.tell()
break
s = self.fp.read(1)
elif i == 0 or i == 65535:
elif i == 0 or i == 0xFFFF:
# padded marker or junk; move on
s = "\xff"
else: