mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Allow for an empty line in EPS header data
This commit is contained in:
parent
3d8035bf31
commit
e107ed6fcf
|
@ -227,9 +227,11 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
#
|
#
|
||||||
# Load EPS header
|
# 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:
|
if len(s) > 255:
|
||||||
raise SyntaxError("not an EPS file")
|
raise SyntaxError("not an EPS file")
|
||||||
|
|
||||||
|
@ -271,9 +273,10 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
else:
|
else:
|
||||||
raise IOError("bad EPS header")
|
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
|
break
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
BIN
Tests/images/zero_bb_emptyline.eps
Normal file
BIN
Tests/images/zero_bb_emptyline.eps
Normal file
Binary file not shown.
|
@ -278,6 +278,16 @@ class TestFileEps(PillowTestCase):
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(img.mode, "RGB")
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user