Merge pull request #2903 from radarhere/eps

Allow for an empty line in EPS header data
This commit is contained in:
wiredfool 2017-12-27 12:13:54 +00:00 committed by GitHub
commit bbe8076d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 39 deletions

View File

@ -227,9 +227,11 @@ class EpsImageFile(ImageFile.ImageFile):
#
# Load EPS header
s = fp.readline().strip('\r\n')
s_raw = fp.readline()
s = s_raw.strip('\r\n')
while s:
while s_raw:
if s:
if len(s) > 255:
raise SyntaxError("not an EPS file")
@ -271,9 +273,10 @@ class EpsImageFile(ImageFile.ImageFile):
else:
raise IOError("bad EPS header")
s = fp.readline().strip('\r\n')
s_raw = fp.readline()
s = s_raw.strip('\r\n')
if s[:1] != "%":
if s and s[:1] != "%":
break
#

Binary file not shown.

View File

@ -278,6 +278,16 @@ class TestFileEps(PillowTestCase):
# Assert
self.assertEqual(img.mode, "RGB")
def test_emptyline(self):
# Test file includes an empty line in the header data
emptyline_file = "Tests/images/zero_bb_emptyline.eps"
image = Image.open(emptyline_file)
image.load()
self.assertEqual(image.mode, "RGB")
self.assertEqual(image.size, (460, 352))
self.assertEqual(image.format, "EPS")
if __name__ == '__main__':
unittest.main()