Skip to content

Commit

Permalink
test+fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pubpub-zz committed May 11, 2024
1 parent 770aaba commit a37b73f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pypdf/generic/_image_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def extract_inline_A85(stream: StreamType) -> bytes:
data += buf[: loc + 2]
stream.seek(-len(buf) + loc + 2, 1)
break
elif len(buf) == 2: # end of buffer
data += buf
break
data += buf[:-1] # back by one char in case of in the middle of ~>
stream.seek(-1, 1)

Check warning on line 106 in pypdf/generic/_image_inline.py

View check run for this annotation

Codecov / codecov/patch

pypdf/generic/_image_inline.py#L105-L106

Added lines #L105 - L106 were not covered by tests

Expand Down
5 changes: 5 additions & 0 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Test the pypdf.generic module."""

from base64 import a85encode
from copy import deepcopy
from io import BytesIO
from pathlib import Path
Expand Down Expand Up @@ -1360,8 +1361,12 @@ def test_array_operators():
def test_unitary_extract_inline_buffer_empty():
with pytest.raises(PdfReadError):
extract_inline_AHex(BytesIO())
with pytest.raises(PdfReadError):
extract_inline_AHex(BytesIO(4095 * b"00" + b" "))
with pytest.raises(PdfReadError):
extract_inline_A85(BytesIO())
with pytest.raises(PdfReadError):
extract_inline_A85(BytesIO(a85encode(b"1")))
with pytest.raises(PdfReadError):
extract_inline_RL(BytesIO())

Expand Down

0 comments on commit a37b73f

Please sign in to comment.