Skip to content

Commit 13a640d

Browse files
authored
BUG: check words length in _cmap type1_alternative function (#2310)
Fixes #2290
1 parent 0d0d81b commit 13a640d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pypdf/_cmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ def type1_alternative(
489489
for li in lines:
490490
if li.startswith(b"dup"):
491491
words = [_w for _w in li.split(b" ") if _w != b""]
492-
if words[3] != b"put":
492+
if len(words) > 3 and words[3] != b"put":
493493
continue
494494
try:
495495
i = int(words[1])

tests/test_cmap.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,12 @@ def test_tabs_in_cmap():
210210
name = "iss2173.pdf"
211211
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
212212
reader.pages[0].extract_text()
213+
214+
215+
@pytest.mark.enable_socket()
216+
def test_ignoring_non_put_entries():
217+
"""Issue #2290"""
218+
url = "https://github.com/py-pdf/pypdf/files/13452885/example.pdf"
219+
name = "iss2290.pdf"
220+
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
221+
reader.pages[0].extract_text()

0 commit comments

Comments
 (0)