Skip extra 0xff00 in jpeg

This commit is contained in:
Konstantin Kopachev 2016-06-22 13:36:23 -07:00
parent 30eced6286
commit c8f93c979c
No known key found for this signature in database
GPG Key ID: CECF757E656F4F62
3 changed files with 6 additions and 0 deletions

View File

@ -331,6 +331,8 @@ class JpegImageFile(ImageFile.ImageFile):
elif i == 0 or i == 0xFFFF:
# padded marker or junk; move on
s = b"\xff"
elif i == 0xFF00: # Skip extraneous data (escaped 0xFF)
s = self.fp.read(1)
else:
raise SyntaxError("no marker found")

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

View File

@ -303,6 +303,10 @@ class TestFileJpeg(PillowTestCase):
filename = "Tests/images/junk_jpeg_header.jpg"
Image.open(filename)
def test_ff00_jpeg_header(self):
filename = "Tests/images/jpeg_ff00_header.jpg"
Image.open(filename)
def _n_qtables_helper(self, n, test_file):
im = Image.open(test_file)
f = self.tempfile('temp.jpg')