From f1b2802eb1daa332cd48b4af276368ad8af482eb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 27 Nov 2018 21:09:28 +1100 Subject: [PATCH 1/2] Resolved error for comment extension with zero subblocks --- Tests/images/hopper_zero_comment_subblocks.gif | Bin 0 -> 18316 bytes Tests/test_file_gif.py | 5 +++++ src/PIL/GifImagePlugin.py | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 Tests/images/hopper_zero_comment_subblocks.gif diff --git a/Tests/images/hopper_zero_comment_subblocks.gif b/Tests/images/hopper_zero_comment_subblocks.gif new file mode 100644 index 0000000000000000000000000000000000000000..5f482c042d36d7b498fa05f41bd66b136c061e47 GIT binary patch literal 18316 zcmXVX2~<BLVz$DMguB_ zQAPzt#X2<1ps0vqai|5v0jD3-p=xdUZuHPz;Ho zdGg)`J6=$jD8dO9Y?SYrZ-jMpg(GZ8`-S=)*yPfR?23FhroHGNQvbNh34E*%TK4gQIx7j5?TK#jdSwNq!eo{V!z( zv?fPh%8opp5n8-|@3{jh;E(gMb^0>`o=rw?trzBgpzQ1Zj1ga;+e^ZAjL`TKi| zGtM<;jORuFmKQTs7P3$hJ<}Newj*dPKY2!;JX4kSK$&$zv45c;3ch@=p-4_G*UEuHk#V_MR zNY<6`AFggYcp)sKBlU1+SWIE$;r@Ua8l9uuF~uAdBgil#`cumNUt2;S9vqLYAmhvZhFPtjLNAj<^7D3 zsr^+?D+|l|l=uCnXry1rg+Ts+%0tvr2q6U&tN;|7o@Z8?yox^uA;-$csq!3U)xlg1pSqU&ZD)%ElD507qM!sd(*;sdbd9 zM*|H36(|ok7>$}!dG)8Se@@@s_P>+*wx_tcdIq-Pw!!Dwxq4RDE8D_OfrsH!viQA1~*3ZQY6Ec zk+&%6#`tD=IXN(t88D#a;S8Cb-1&WUtUfb=x9d9Vj&H3Tq3kw;jfj?Sfl_Pk0|_4{r}|-csce z@#>yU_-sh?ig!d|L|b^vmioZlzzAC-SKjjLWZk%GtIdH?HPvV8eipy4vrp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76{H;*pr2eyX$D72;hi}k0TIoZBGG?S ztz%BP2r$1EVc?LV=x?sC{T;RC4*#(bk&dy zPBdil1Og5m3%oesfDx;aKqH3)Y<3QSNK}w0Zx~7&&!x`J_UE9{hS>_i08EAk#u+zv zp*IYV53I~4`G8qtCX25Oh7aZ%q4zunCJIVUfE$UMIfR@V4g>(#L~~23+?ipZ?8Ygmq>zwsK*5bi gV2^jh2jDy$&>LOuz;dpVgISQLMZ)oDtOJ8J0JI@QhX4Qo literal 0 HcmV?d00001 diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index cfa1bb1e7..ffaff7afe 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -435,6 +435,11 @@ class TestFileGif(PillowTestCase): self.assertEqual(reread.info['comment'], im.info['comment']) + def test_zero_comment_subblocks(self): + im = Image.open('Tests/images/hopper_zero_comment_subblocks.gif') + expected = Image.open(TEST_GIF) + self.assert_image_equal(im, expected) + def test_version(self): out = self.tempfile('temp.gif') diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index ecd993cd5..f8d42e6fd 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -202,6 +202,8 @@ class GifImageFile(ImageFile.ImageFile): # comment extension # info["comment"] = block + if not block: + continue elif i8(s) == 255: # # application extension From b2b737b68b06ac448d6c6f799347f244652bedcb Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 27 Nov 2018 21:05:41 +1100 Subject: [PATCH 2/2] Allow arbitrary number of comment extension subblocks --- Tests/test_file_gif.py | 12 ++++++++++++ src/PIL/GifImagePlugin.py | 22 ++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index ffaff7afe..d80b63249 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -435,6 +435,18 @@ class TestFileGif(PillowTestCase): self.assertEqual(reread.info['comment'], im.info['comment']) + def test_comment_over_255(self): + out = self.tempfile('temp.gif') + im = Image.new('L', (100, 100), '#000') + comment = b"Test comment text" + while len(comment) < 256: + comment += comment + im.info['comment'] = comment + im.save(out) + reread = Image.open(out) + + self.assertEqual(reread.info['comment'], comment) + def test_zero_comment_subblocks(self): im = Image.open('Tests/images/hopper_zero_comment_subblocks.gif') expected = Image.open(TEST_GIF) diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index f8d42e6fd..57bca07f7 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -201,9 +201,13 @@ class GifImageFile(ImageFile.ImageFile): # # comment extension # - info["comment"] = block - if not block: - continue + while block: + if "comment" in info: + info["comment"] += block + else: + info["comment"] = block + block = self.data() + continue elif i8(s) == 255: # # application extension @@ -538,12 +542,14 @@ def _write_local_header(fp, im, offset, flags): o8(0)) if "comment" in im.encoderinfo and \ - 1 <= len(im.encoderinfo["comment"]) <= 255: + 1 <= len(im.encoderinfo["comment"]): fp.write(b"!" + - o8(254) + # extension intro - o8(len(im.encoderinfo["comment"])) + - im.encoderinfo["comment"] + - o8(0)) + o8(254)) # extension intro + for i in range(0, len(im.encoderinfo["comment"]), 255): + subblock = im.encoderinfo["comment"][i:i+255] + fp.write(o8(len(subblock)) + + subblock) + fp.write(o8(0)) if "loop" in im.encoderinfo: number_of_loops = im.encoderinfo["loop"] fp.write(b"!" +