Skip to content

Commit

Permalink
BUG: Cope with missing /I in articles (#2134)
Browse files Browse the repository at this point in the history
Closes #2089
  • Loading branch information
pubpub-zz committed Sep 3, 2023
1 parent b8d3bea commit 3acee1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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"]):
] 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 @@ -1697,6 +1697,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

0 comments on commit 3acee1b

Please sign in to comment.