mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
add eps test for bad BoundingBox, good ImageData
This commit is contained in:
parent
3d6770d0f3
commit
be9aea35a8
|
@ -56,7 +56,10 @@ simple_eps_file_with_comments = (
|
||||||
simple_eps_file_without_version = simple_eps_file[1:]
|
simple_eps_file_without_version = simple_eps_file[1:]
|
||||||
simple_eps_file_without_boundingbox = simple_eps_file[:1] + simple_eps_file[2:]
|
simple_eps_file_without_boundingbox = simple_eps_file[:1] + simple_eps_file[2:]
|
||||||
simple_eps_file_with_invalid_boundingbox = (
|
simple_eps_file_with_invalid_boundingbox = (
|
||||||
simple_eps_file[:1] + (b"%%BoundingBox",) + simple_eps_file[2:]
|
simple_eps_file[:1] + (b"%%BoundingBox: a b c d",) + simple_eps_file[2:]
|
||||||
|
)
|
||||||
|
simple_eps_file_with_invalid_boundingbox_valid_imagedata = (
|
||||||
|
simple_eps_file_with_invalid_boundingbox + (b"%ImageData: 100 100 8 3",)
|
||||||
)
|
)
|
||||||
simple_eps_file_with_long_ascii_comment = (
|
simple_eps_file_with_long_ascii_comment = (
|
||||||
simple_eps_file[:2] + (b"%%Comment: " + b"X" * 300,) + simple_eps_file[2:]
|
simple_eps_file[:2] + (b"%%Comment: " + b"X" * 300,) + simple_eps_file[2:]
|
||||||
|
@ -128,6 +131,17 @@ def test_invalid_boundingbox_comment(prefix):
|
||||||
EpsImagePlugin.EpsImageFile(data)
|
EpsImagePlugin.EpsImageFile(data)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
||||||
|
def test_invalid_boundingbox_comment_valid_imagedata_comment(prefix):
|
||||||
|
data = io.BytesIO(
|
||||||
|
prefix + b"\n".join(simple_eps_file_with_invalid_boundingbox_valid_imagedata)
|
||||||
|
)
|
||||||
|
with Image.open(data) as img:
|
||||||
|
assert img.mode == "RGB"
|
||||||
|
assert img.size == (100, 100)
|
||||||
|
assert img.format == "EPS"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
@pytest.mark.parametrize("prefix", (b"", simple_binary_header))
|
||||||
def test_ascii_comment_too_long(prefix):
|
def test_ascii_comment_too_long(prefix):
|
||||||
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_ascii_comment))
|
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_ascii_comment))
|
||||||
|
|
|
@ -314,7 +314,7 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
# Check for an "ImageData" descriptor
|
# Check for an "ImageData" descriptor
|
||||||
|
|
||||||
# Encoded bitmapped image.
|
# Encoded bitmapped image.
|
||||||
x, y, bi, mo = byte_arr[11:].split(None, 7)[:4]
|
x, y, bi, mo = byte_arr[11:bytes_read].split(None, 7)[:4]
|
||||||
|
|
||||||
if int(bi) == 1:
|
if int(bi) == 1:
|
||||||
self.mode = "1"
|
self.mode = "1"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user