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

Fix #297 : fix corruption in startxref or xref table #788

Merged
merged 6 commits into from
Apr 27, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
reformatting with black
applied only on test_reader as recommanded
  • Loading branch information
pubpub-zz committed Apr 24, 2022
commit cd2df385d0fd91c03513f190cb0f79db4f57958d
10 changes: 5 additions & 5 deletions Tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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 PdfReadError,PdfReadWarning
from PyPDF2.errors import PdfReadError, PdfReadWarning
from PyPDF2.filters import _xobj_to_image

TESTS_ROOT = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_get_images_raw(strict, with_prev_0, should_fail):
pdf_data.find(b"4 0 obj"),
pdf_data.find(b"5 0 obj"),
b"/Prev 0 " if with_prev_0 else b"",
pdf_data.find(b"xref") - 1, # -1 due to double % at the beginning
pdf_data.find(b"xref") - 1, # -1 due to double % at the beginning
)
pdf_stream = io.BytesIO(pdf_data)
if should_fail:
Expand All @@ -218,10 +218,10 @@ def test_issue297():
path = os.path.join(RESOURCE_ROOT, "issue-297.pdf")
with pytest.raises(PdfReadWarning) as exc:
print(exc)
MartinThoma marked this conversation as resolved.
Show resolved Hide resolved
reader = PdfFileReader(path,strict=True)
reader = PdfFileReader(path, strict=True)
reader.getPage(0)
assert ( exc.value.args[0].find("startxref") > 0)
reader = PdfFileReader(path,strict=False)
assert exc.value.args[0].find("startxref") > 0
MartinThoma marked this conversation as resolved.
Show resolved Hide resolved
reader = PdfFileReader(path, strict=False)
reader.getPage(0)


Expand Down