Skip to content

Commit 1b6e68e

Browse files
authored
Merge pull request #7823 from radarhere/png_iccp
2 parents 4e92ee0 + b80b30d commit 1b6e68e

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed
4.03 KB
Loading

Tests/test_file_png.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ def test_textual_chunks_after_idat(self) -> None:
619619
with Image.open("Tests/images/hopper_idat_after_image_end.png") as im:
620620
assert im.text == {"TXT": "VALUE", "ZIP": "VALUE"}
621621

622+
def test_unknown_compression_method(self) -> None:
623+
with pytest.raises(SyntaxError, match="Unknown compression method"):
624+
PngImagePlugin.PngImageFile("Tests/images/unknown_compression_method.png")
625+
622626
def test_padded_idat(self) -> None:
623627
# This image has been manually hexedited
624628
# so that the IDAT chunk has padding at the end

src/PIL/PngImagePlugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,8 @@ def chunk_iCCP(self, pos, length):
392392
# Compressed profile n bytes (zlib with deflate compression)
393393
i = s.find(b"\0")
394394
logger.debug("iCCP profile name %r", s[:i])
395-
logger.debug("Compression method %s", s[i])
396-
comp_method = s[i]
395+
comp_method = s[i + 1]
396+
logger.debug("Compression method %s", comp_method)
397397
if comp_method != 0:
398398
msg = f"Unknown compression method {comp_method} in iCCP chunk"
399399
raise SyntaxError(msg)

0 commit comments

Comments
 (0)