mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-29 18:23:24 +03:00
Merge 518da5a15f
into 7e4d8e2f55
This commit is contained in:
commit
b236b03076
|
@ -288,12 +288,13 @@ def test_non_integer_token(tmp_path: Path) -> None:
|
|||
pass
|
||||
|
||||
|
||||
def test_header_token_too_long(tmp_path: Path) -> None:
|
||||
@pytest.mark.parametrize("data", (b"P3\x0cAAAAAAAAAA\xee", b"P6\n 01234567890"))
|
||||
def test_header_token_too_long(tmp_path: Path, data: bytes) -> None:
|
||||
path = tmp_path / "temp.ppm"
|
||||
with open(path, "wb") as f:
|
||||
f.write(b"P6\n 01234567890")
|
||||
f.write(data)
|
||||
|
||||
with pytest.raises(ValueError, match="Token too long in file header: 01234567890"):
|
||||
with pytest.raises(ValueError, match="Token too long in file header: "):
|
||||
with Image.open(path):
|
||||
pass
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ class PpmImageFile(ImageFile.ImageFile):
|
|||
msg = "Reached EOF while reading header"
|
||||
raise ValueError(msg)
|
||||
elif len(token) > 10:
|
||||
msg = f"Token too long in file header: {token.decode()}"
|
||||
raise ValueError(msg)
|
||||
msg_too_long = b"Token too long in file header: %s" % token
|
||||
raise ValueError(msg_too_long)
|
||||
return token
|
||||
|
||||
def _open(self) -> None:
|
||||
|
|
Loading…
Reference in New Issue
Block a user