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

ROB : fix loading of file from #134 #1167

Merged
merged 2 commits into from Jul 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion PyPDF2/_cmap.py
Expand Up @@ -182,7 +182,7 @@ def parse_to_unicode(
cm = prepare_cm(ft)
for l in cm.split(b"\n"):
process_rg, process_char = process_cm_line(
l, process_rg, process_char, map_dict, int_entry
l.strip(b" "), process_rg, process_char, map_dict, int_entry
)

for a, value in map_dict.items():
Expand Down
2 changes: 1 addition & 1 deletion PyPDF2/_reader.py
Expand Up @@ -1303,7 +1303,7 @@ def _basic_validation(self, stream: StreamType) -> None:
stream.seek(0, os.SEEK_END)

def _find_eof_marker(self, stream: StreamType) -> None:
last_mb = stream.tell() - 1024 * 1024 + 1 # offset of last MB of stream
last_mb = 8 # to parse whole file
line = b""
while line[:5] != b"%%EOF":
if stream.tell() < last_mb:
Expand Down
10 changes: 4 additions & 6 deletions tests/test_reader.py
Expand Up @@ -11,11 +11,7 @@
from PyPDF2.constants import ImageAttributes as IA
from PyPDF2.constants import PageAttributes as PG
from PyPDF2.constants import Ressources as RES
from PyPDF2.errors import (
STREAM_TRUNCATED_PREMATURELY,
PdfReadError,
PdfReadWarning,
)
from PyPDF2.errors import PdfReadError, PdfReadWarning
from PyPDF2.filters import _xobj_to_image
from PyPDF2.generic import Destination

Expand Down Expand Up @@ -396,7 +392,9 @@ def test_read_malformed_header():
def test_read_malformed_body():
with pytest.raises(PdfReadError) as exc:
PdfReader(io.BytesIO(b"%PDF-"), strict=True)
assert exc.value.args[0] == STREAM_TRUNCATED_PREMATURELY
assert (
exc.value.args[0] == "EOF marker not found"
) # used to be:STREAM_TRUNCATED_PREMATURELY


def test_read_prev_0_trailer():
Expand Down