mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-09-24 13:07:00 +03:00
Seek past BeginBinary data when parsing metadata
This commit is contained in:
parent
abfdbdd6ce
commit
222933df54
|
@ -197,6 +197,14 @@ def test_load_long_binary_data(prefix: bytes) -> None:
|
||||||
assert img.format == "EPS"
|
assert img.format == "EPS"
|
||||||
|
|
||||||
|
|
||||||
|
def test_begin_binary() -> None:
|
||||||
|
with open("Tests/images/eps/binary_preview_map.eps", "rb") as fp:
|
||||||
|
data = bytearray(fp.read())
|
||||||
|
data[76875 : 76875 + 11] = b"%" * 11
|
||||||
|
with Image.open(io.BytesIO(data)) as img:
|
||||||
|
assert img.size == (399, 480)
|
||||||
|
|
||||||
|
|
||||||
@mark_if_feature_version(
|
@mark_if_feature_version(
|
||||||
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
|
pytest.mark.valgrind_known_error, "libjpeg_turbo", "2.0", reason="Known Failing"
|
||||||
)
|
)
|
||||||
|
|
|
@ -354,6 +354,9 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
read_comment(s)
|
read_comment(s)
|
||||||
elif bytes_mv[:9] == b"%%Trailer":
|
elif bytes_mv[:9] == b"%%Trailer":
|
||||||
trailer_reached = True
|
trailer_reached = True
|
||||||
|
elif bytes_mv[:14] == b"%%BeginBinary:":
|
||||||
|
bytecount = int(byte_arr[14:bytes_read])
|
||||||
|
self.fp.seek(bytecount, os.SEEK_CUR)
|
||||||
bytes_read = 0
|
bytes_read = 0
|
||||||
|
|
||||||
# A "BoundingBox" is always required,
|
# A "BoundingBox" is always required,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user