@@ -374,9 +374,8 @@ def test_iss1787():
374
374
obj = data .indirect_reference .get_object ()
375
375
obj ["/DecodeParms" ][NameObject ("/Columns" )] = NumberObject (1000 )
376
376
obj .decoded_self = None
377
- with pytest .raises (PdfReadError ) as exc :
378
- reader .pages [0 ].images [0 ]
379
- assert exc .value .args [0 ] == "Image data is not rectangular"
377
+ with pytest .raises (expected_exception = PdfReadError , match = "^Unsupported PNG filter 244$" ):
378
+ _ = reader .pages [0 ].images [0 ]
380
379
381
380
382
381
@pytest .mark .enable_socket
@@ -672,3 +671,22 @@ def test_flate_decode__image_is_none_due_to_size_limit(caplog):
672
671
"Failed loading image: Image size (180000000 pixels) exceeds limit of "
673
672
"178956970 pixels, could be decompression bomb DOS attack."
674
673
) in caplog .messages
674
+
675
+
676
+ @pytest .mark .enable_socket
677
+ def test_flate_decode__not_rectangular (caplog ):
678
+ url = "https://github.com/user-attachments/files/19663603/issue3241_compressed.txt"
679
+ name = "issue3241.txt"
680
+ data = get_data_from_url (url , name = name )
681
+ decode_parms = DictionaryObject ()
682
+ decode_parms [NameObject ("/Predictor" )] = NumberObject (15 )
683
+ decode_parms [NameObject ("/Columns" )] = NumberObject (4881 )
684
+ actual = FlateDecode .decode (data = data , decode_parms = decode_parms )
685
+ actual_image = BytesIO ()
686
+ Image .frombytes (mode = "1" , size = (4881 , 81 ), data = actual ).save (actual_image , format = "png" )
687
+
688
+ url = "https://github.com/user-attachments/assets/c5695850-c076-4255-ab72-7c86851a4a04"
689
+ name = "issue3241.png"
690
+ expected = get_data_from_url (url , name = name )
691
+ assert actual_image .getvalue () == expected
692
+ assert caplog .messages == ["Image data is not rectangular. Adding padding." ]
0 commit comments