Use latest version of objects from object streams (#1)#169
Open
mjbryant wants to merge 5 commits intopmaupin:masterfrom
Open
Use latest version of objects from object streams (#1)#169mjbryant wants to merge 5 commits intopmaupin:masterfrom
mjbryant wants to merge 5 commits intopmaupin:masterfrom
Conversation
* Load object streams starting from latest, and don't clobber later versions of objects from object streams * Ignore pyenv's local file
Owner
|
Thank you. I will have some time to look at this late next month.
…On Sat, Jun 29, 2019 at 4:06 PM Michael Bryant ***@***.***> wrote:
Previously, when an object was parsed from an object stream and it
referenced an indirect object, it'd pull the current version of that object
at parse time. This means if you have an object stream that declares
updated versions of two objects, the first of which references the second,
the first object will have the incorrect old value for the second object.
For example, if the content of an object stream is something like
(formatted for clarity, and with probably incorrect offsets):
1 0 2 40
<</Count 3 /Kids [2 0 R] /Type /Pages>>
<</Count 3 /Kids [4 0 R 5 0 R 6 0 R] /Parent 1 0 R /Type /Pages>>
The object stream here defines both objects (1, 0) and (2, 0). If this is
an incremental update for (2, 0), the previous version of the code would
make /Kids for (1, 0) the previous version of (2, 0). This was manifesting
in several PDFs we found in the wild as incorrect page counts. The PDFs had
added additional pages in incremental updates, and the old /Pages objects
with incorrect kids were getting used.
I've ran this branch against all pdfrw tests and they all still pass. This
includes roundtrips for lots of existing PDFs, so I'm fairly confident that
it's not going to break the status quo. It also fixes several of the PDFs
that broke for us on pdfrw master.
------------------------------
You can view, comment on, or merge this pull request online at:
#169
Commit Summary
- Use latest version of objects from object streams (#1)
File Changes
- *M* .gitignore
<https://github.com/pmaupin/pdfrw/pull/169/files#diff-0> (6)
- *M* pdfrw/pdfreader.py
<https://github.com/pmaupin/pdfrw/pull/169/files#diff-1> (42)
Patch Links:
- https://github.com/pmaupin/pdfrw/pull/169.patch
- https://github.com/pmaupin/pdfrw/pull/169.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#169?email_source=notifications&email_token=AASE2NRWIUTN3RYLTILWOCLP47FF5A5CNFSM4H4LHJSKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4OZCAA>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AASE2NUKTJHOM2LSDSSUVBLP47FF5ANCNFSM4H4LHJSA>
.
|
This file contains hidden or 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
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.
Previously, when an object was parsed from an object stream and it referenced an indirect object, it'd pull the current version of that object at parse time. This means if you have an object stream that declares updated versions of two objects, the first of which references the second, the first object will have the incorrect old value for the second object. For example, if the content of an object stream is something like (formatted for clarity, and with probably incorrect offsets):
The object stream here defines both objects (1, 0) and (2, 0). If this is an incremental update for (2, 0), the previous version of the code would make /Kids for (1, 0) the previous version of (2, 0). This was manifesting in several PDFs we found in the wild as incorrect page counts. The PDFs had added additional pages in incremental updates, and the old /Pages objects with incorrect kids were getting used.
I've ran this branch against all pdfrw tests and they all still pass. This includes roundtrips for lots of existing PDFs, so I'm fairly confident that it's not going to break the status quo. It also fixes several of the PDFs that broke for us on pdfrw master.