Skip to content

Commit bc12516

Browse files
authored
ROB: Invalid startxref pointing 1 char before (#1784)
Fixes #1756
1 parent 6836174 commit bc12516

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

pypdf/_reader.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,8 @@ def _get_xref_issues(stream: StreamType, startxref: int) -> int:
18791879
"""
18801880
stream.seek(startxref - 1, 0) # -1 to check character before
18811881
line = stream.read(1)
1882+
if line == b"j":
1883+
line = stream.read(1)
18821884
if line not in b"\r\n \t":
18831885
return 1
18841886
line = stream.read(4)

tests/test_reader.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,3 +1392,12 @@ def test_broken_file_header():
13921392
pdf_data.find(b"xref") - 1,
13931393
)
13941394
PdfReader(io.BytesIO(pdf_data))
1395+
1396+
1397+
@pytest.mark.enable_socket()
1398+
def test_iss1756():
1399+
url = "https://github.com/py-pdf/pypdf/files/11105591/641-Attachment-B-Pediatric-Cardiac-Arrest-8-1-2019.pdf"
1400+
name = "iss1756.pdf"
1401+
in_pdf = PdfReader(BytesIO(get_pdf_from_url(url, name=name)))
1402+
in_pdf.trailer["/ID"]
1403+
# removed to cope with missing cryptodome during commit check : len(in_pdf.pages)

0 commit comments

Comments
 (0)