File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -634,7 +634,7 @@ def read_unsized_from_stream(
634634 if length is None : # if the PDF is damaged
635635 length = - 1
636636 pstart = stream .tell ()
637- if length > 0 :
637+ if length >= 0 :
638638 data ["__streamdata__" ] = stream .read (length )
639639 else :
640640 data ["__streamdata__" ] = read_until_regex (
Original file line number Diff line number Diff line change @@ -1265,3 +1265,14 @@ def test_build_link__go_to_action_without_destination():
12651265 for page in reader .pages :
12661266 writer .add_page (page )
12671267 assert len (writer .pages ) == len (reader .pages )
1268+
1269+
1270+ @pytest .mark .enable_socket
1271+ def test_dictionaryobject__length_0_stream ():
1272+ """Test for issue #3052."""
1273+ url = "https://github.com/user-attachments/files/18734105/correct.pdf"
1274+ name = "issue3052.pdf"
1275+ writer = PdfWriter (clone_from = BytesIO (get_data_from_url (url , name = name )))
1276+ output = BytesIO ()
1277+ writer .write (output )
1278+ assert b"\n 8 0 obj\n <<\n /Length 0\n >>\n stream\n \n endstream\n endobj\n " in output .getvalue ()
You can’t perform that action at this time.
0 commit comments