Skip to content

Commit

Permalink
Merge pull request #7823 from radarhere/png_iccp
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Mar 11, 2024
2 parents 4e92ee0 + b80b30d commit 1b6e68e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file added Tests/images/unknown_compression_method.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Tests/test_file_png.py
Expand Up @@ -619,6 +619,10 @@ def test_textual_chunks_after_idat(self) -> None:
with Image.open("Tests/images/hopper_idat_after_image_end.png") as im:
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:
# This image has been manually hexedited
# so that the IDAT chunk has padding at the end
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/PngImagePlugin.py
Expand Up @@ -392,8 +392,8 @@ def chunk_iCCP(self, pos, length):
# Compressed profile n bytes (zlib with deflate compression)
i = s.find(b"\0")
logger.debug("iCCP profile name %r", s[:i])
logger.debug("Compression method %s", s[i])
comp_method = s[i]
comp_method = s[i + 1]
logger.debug("Compression method %s", comp_method)
if comp_method != 0:
msg = f"Unknown compression method {comp_method} in iCCP chunk"
raise SyntaxError(msg)
Expand Down

0 comments on commit 1b6e68e

Please sign in to comment.