diff --git a/pypdf/generic/_data_structures.py b/pypdf/generic/_data_structures.py index 3fc913c23..91f59f746 100644 --- a/pypdf/generic/_data_structures.py +++ b/pypdf/generic/_data_structures.py @@ -1016,7 +1016,7 @@ def __parse_content_stream(self, stream: StreamType) -> None: # encountering a comment -- but read_object assumes that # following the comment must be the object we're trying to # read. In this case, it could be an operator instead. - while peek not in (b"\r", b"\n"): + while peek not in (b"\r", b"\n", b""): peek = stream.read(1) else: operands.append(read_object(stream, None, self.forced_encoding)) diff --git a/requirements/ci-3.11.txt b/requirements/ci-3.11.txt index a54dddde5..3cec546a8 100644 --- a/requirements/ci-3.11.txt +++ b/requirements/ci-3.11.txt @@ -50,10 +50,13 @@ pytest==7.2.2 # -r requirements/ci.in # pytest-benchmark # pytest-socket + # pytest-timeout pytest-benchmark==4.0.0 # via -r requirements/ci.in pytest-socket==0.6.0 # via -r requirements/ci.in +pytest-timeout==2.1.0 + # via -r requirements/ci.in ruff==0.0.259 # via -r requirements/ci.in typeguard==3.0.2 diff --git a/requirements/ci.in b/requirements/ci.in index 1d41d3202..2150ddf0f 100644 --- a/requirements/ci.in +++ b/requirements/ci.in @@ -9,6 +9,7 @@ pycryptodome pytest pytest-benchmark pytest-socket +pytest-timeout typeguard types-dataclasses types-Pillow diff --git a/requirements/ci.txt b/requirements/ci.txt index a7a12e49a..235b13e07 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -62,10 +62,13 @@ pytest==7.0.1 # -r requirements/ci.in # pytest-benchmark # pytest-socket + # pytest-timeout pytest-benchmark==3.4.1 # via -r requirements/ci.in pytest-socket==0.4.1 # via -r requirements/ci.in +pytest-timeout==2.1.0 + # via -r requirements/ci.in six==1.16.0 # via flake8-print tomli==1.2.3 diff --git a/tests/test_reader.py b/tests/test_reader.py index 8a0beb987..f606757e9 100644 --- a/tests/test_reader.py +++ b/tests/test_reader.py @@ -1401,3 +1401,13 @@ def test_iss1756(): in_pdf = PdfReader(BytesIO(get_pdf_from_url(url, name=name))) in_pdf.trailer["/ID"] # removed to cope with missing cryptodome during commit check : len(in_pdf.pages) + + +@pytest.mark.enable_socket() +@pytest.mark.timeout(30) +def test_iss1825(): + url = "https://github.com/py-pdf/pypdf/files/11367871/MiFO_LFO_FEIS_NOA_Published.3.pdf" + name = "iss1825.pdf" + reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name))) + page = reader.pages[0] + page.extract_text()