Skip to content

Commit

Permalink
BUG: check words length in _cmap type1_alternative function (#2310)
Browse files Browse the repository at this point in the history
Fixes #2290
  • Loading branch information
Takher authored Nov 26, 2023
1 parent 0d0d81b commit 13a640d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pypdf/_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def type1_alternative(
for li in lines:
if li.startswith(b"dup"):
words = [_w for _w in li.split(b" ") if _w != b""]
if words[3] != b"put":
if len(words) > 3 and words[3] != b"put":
continue
try:
i = int(words[1])
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,12 @@ def test_tabs_in_cmap():
name = "iss2173.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
reader.pages[0].extract_text()


@pytest.mark.enable_socket()
def test_ignoring_non_put_entries():
"""Issue #2290"""
url = "https://github.com/py-pdf/pypdf/files/13452885/example.pdf"
name = "iss2290.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
reader.pages[0].extract_text()

0 comments on commit 13a640d

Please sign in to comment.