Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: check words length in _cmap type1_alternative function #2310

Merged
merged 6 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading