-
Notifications
You must be signed in to change notification settings - Fork 284
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
Refactor Objects::recover_stream_length #1304
Open
m-holger
wants to merge
15
commits into
qpdf:main
Choose a base branch
from
m-holger:recover
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make resolve resolve responsible to try again after xref reconstruction rather than returning false to indicate failure. Rename to resolve_all.
Remove invalid objects introduced into the object table during xref table parsing. At the moment, such invalid objects could override valid objects if valid gen < invalid gen. Once the object table is indexed by object id only, the invalid object will prevent valid objects with the same id entering the object table. The additional test case uses good10.pdf, with the dangling reference in the trailer replaced with 3 1 R. Prior to this commit, this caused the page object 3 0 to be masked and replaced with a null object.
Store last used id as a data member. Update when calling next_id / inserting a new object (which only occurs in make_indirect and get_for_json). Add new methods initialize to calculate the initial value for last_id and last_id to query it. Use initialize in QPDF::fixDanglingReferences, which is redundant. Refactor make_indirect to use update_table.
Decompose into new methods update_entry and Entry::update.
Allow for the fact that when processing JSON input we cannot determine whether references are dangling until the whole input has been processed. We handle this by optimistically storing references in the object table. When additional gens are encountered for the same object we store them in the new map unconfirmed_objects. Once processing is complete we clean up the object table and clear unconfirmed_objects. New test cases are adapted from manual-qpdf-json.json etc.
Tests use a modified dangling-bad-xref.pdf.
Use start of next object or xref table to put an upper bound on object length. Tests reuse existing incremental-1.pdf. incremental-1-bad.pdf is incremental-1.pdf with whitespace inserted after object 1 0.
Also, use break to terminate loop in Xref_table::read.
Leave input source correctly positioned to find 'endobj' next.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1304 +/- ##
==========================================
- Coverage 93.22% 93.19% -0.03%
==========================================
Files 308 309 +1
Lines 33795 33933 +138
Branches 4117 4152 +35
==========================================
+ Hits 31504 31625 +121
- Misses 2291 2308 +17 ☔ View full report in Codecov by Sentry. |
m-holger
force-pushed
the
recover
branch
2 times, most recently
from
November 1, 2024 16:22
09366bd
to
640676a
Compare
Change how the maximum stream length is calculated. For streams not in the xref table, instead of returning 0 length return the maximum length that does not overlap with a known object or xref table.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change how the maximum stream length is calculated. For streams not in the xref table, instead of returning 0 length return the maximum length that does not overlap with a known object or xref table. For further detail see #1271.
PR is last 3 commits only, remainder is #1302 and earlier.