Repository navigation
Fall back to the /Catalog dictionary when a PDF file has no trailer - #22309
Closed
andrewfader wants to merge 4 commits into
Closed
andrewfader wants to merge 4 commits into
andrewfader wants to merge 4 commits into
Conversation
A file truncated before its XRef table and trailer, e.g. an incomplete download, may still contain its /Catalog dictionary. Rather than failing with "Invalid PDF structure.", use it as the /Root when no trailer dictionary can be found.
Snuffleupagus
requested changes
Oct 26, 2026
Snuffleupagus
left a comment
Collaborator
There was a problem hiding this comment.
Can you please provide a real-world example of a (corrupt) PDF that this patch fixes?
Contributor
Author
|
Yes, I can. None of these issues is theoretical: I will find representative PDFs and get back to you. Some of the PDFs might be confidential/proprietary, so I have to possibly contrive an example PDF based on the real one. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
andrewfader
marked this pull request as draft
October 27, 2026 20:53
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
andrewfader
marked this pull request as ready for review
October 27, 2026 21:00
andrewfader
marked this pull request as draft
October 27, 2026 21:02
Collaborator
|
Sorry, but what appears to be (entirely?) AI generated patches for issues that have never actually been reported before isn't a good use of human reviewer time. If these are real problems, please submit proper issues (filling out the ISSUE_TEMPLATE correctly) that include the affected PDFs and/or runnable test-cases. |
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.
When a file is truncated before its XRef table and trailer, e.g. an incomplete download,
XRef.indexObjectsfinds no trailer dictionary and throws "Invalid PDF structure.", even though the /Catalog dictionary and pages may be intact.This extends the fallback from issue 18986: if no dictionary with a /Root entry is found, the first /Catalog dictionary is used as the /Root.
The new unit test fails without the patch with "Invalid PDF structure.".