mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
EOF ends not just the trailer, but also the file
This commit is contained in:
parent
8064adad7a
commit
094f23dd5c
BIN
Tests/images/zero_bb_eof_before_boundingbox.eps
Normal file
BIN
Tests/images/zero_bb_eof_before_boundingbox.eps
Normal file
Binary file not shown.
|
@ -406,10 +406,16 @@ def test_timeout(test_file):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_boundary_box_in_trailer():
|
def test_bounding_box_in_trailer():
|
||||||
# Check whether boundary boxes are parsed in the same way
|
# Check bounding boxes are parsed in the same way
|
||||||
# when specified in the header or the trailer
|
# when specified in the header and the trailer
|
||||||
with Image.open("Tests/images/zero_bb_trailer.eps") as trailer_image, Image.open(
|
with Image.open("Tests/images/zero_bb_trailer.eps") as trailer_image, Image.open(
|
||||||
FILE1
|
FILE1
|
||||||
) as header_image:
|
) as header_image:
|
||||||
assert trailer_image.size == header_image.size
|
assert trailer_image.size == header_image.size
|
||||||
|
|
||||||
|
|
||||||
|
def test_eof_before_bounding_box():
|
||||||
|
with pytest.raises(OSError):
|
||||||
|
with Image.open("Tests/images/zero_bb_eof_before_boundingbox.eps"):
|
||||||
|
pass
|
||||||
|
|
|
@ -367,10 +367,9 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
# Load EPS trailer
|
# Load EPS trailer
|
||||||
|
|
||||||
# if this line starts with "%%EOF",
|
# if this line starts with "%%EOF",
|
||||||
# then we've reached the end of the trailer
|
# then we've reached the end of the file
|
||||||
if bytes_mv[:5] == b"%%EOF":
|
if bytes_mv[:5] == b"%%EOF":
|
||||||
reading_trailer_comments = False
|
break
|
||||||
continue
|
|
||||||
|
|
||||||
s = str(bytes_mv[:bytes_read], "latin-1")
|
s = str(bytes_mv[:bytes_read], "latin-1")
|
||||||
_read_comment(s)
|
_read_comment(s)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user