Merge pull request #7823 from radarhere/png_iccp

This commit is contained in:
Hugo van Kemenade 2024-03-11 17:42:22 +02:00 committed by GitHub
commit 1b6e68eaae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -619,6 +619,10 @@ class TestFilePng:
with Image.open("Tests/images/hopper_idat_after_image_end.png") as im: with Image.open("Tests/images/hopper_idat_after_image_end.png") as im:
assert im.text == {"TXT": "VALUE", "ZIP": "VALUE"} assert im.text == {"TXT": "VALUE", "ZIP": "VALUE"}
def test_unknown_compression_method(self) -> None:
with pytest.raises(SyntaxError, match="Unknown compression method"):
PngImagePlugin.PngImageFile("Tests/images/unknown_compression_method.png")
def test_padded_idat(self) -> None: def test_padded_idat(self) -> None:
# This image has been manually hexedited # This image has been manually hexedited
# so that the IDAT chunk has padding at the end # so that the IDAT chunk has padding at the end

View File

@ -392,8 +392,8 @@ class PngStream(ChunkStream):
# Compressed profile n bytes (zlib with deflate compression) # Compressed profile n bytes (zlib with deflate compression)
i = s.find(b"\0") i = s.find(b"\0")
logger.debug("iCCP profile name %r", s[:i]) logger.debug("iCCP profile name %r", s[:i])
logger.debug("Compression method %s", s[i]) comp_method = s[i + 1]
comp_method = s[i] logger.debug("Compression method %s", comp_method)
if comp_method != 0: if comp_method != 0:
msg = f"Unknown compression method {comp_method} in iCCP chunk" msg = f"Unknown compression method {comp_method} in iCCP chunk"
raise SyntaxError(msg) raise SyntaxError(msg)