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: Cope with missing /I in articles #2134

Merged
merged 5 commits into from
Sep 3, 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/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,7 @@ def add_filtered_articles(
thr = thr.get_object()
if thr.indirect_reference.idnum not in self._id_translated[
id(reader)
] and fltr.search(thr["/I"]["/Title"]):
MartinThoma marked this conversation as resolved.
Show resolved Hide resolved
] and fltr.search((thr["/I"] if "/I" in thr else {}).get("/Title", "")):
self._add_articles_thread(thr, pages, reader)

def _get_cloned_page(
Expand Down
10 changes: 10 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,16 @@ def test_no_t_in_articles():
writer.append(reader)


@pytest.mark.enable_socket()
def test_no_i_in_articles():
"""Cf #2089"""
url = "https://github.com/py-pdf/pypdf/files/12352793/kim2002.pdf"
name = "iss2089.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
writer = PdfWriter()
writer.append(reader)


@pytest.mark.enable_socket()
def test_damaged_pdf_length_returning_none():
"""
Expand Down