Repository navigation
Identify object-stream members by header number; accept untyped page-tree nodes - #613
Merged
Merged
Conversation
…tree nodes The loader matched compressed objects by the xref's in-stream index and stored whatever object sat at that index under the requested number. An xref whose index field is too narrow for a large object stream wraps the index, so the catalog resolved to an unrelated object. The stream header already names each member's object number, so members are now inserted under that number; objects the header does not list stay absent with a diagnostic. The unused index is dropped from CrossReferenceEntryType. Page-tree kids without /Type are now a branch when they have /Kids and a page otherwise, instead of failing the read. Fixes #573 Fixes #605 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conformance readsDocuments that Safe-PDF reads differently from the base commit, compared with PDFium. A read pdf.js corpus1009 documents compared with Regressions
Improvements
840 documents of the PDFium corpus read as on Details are in the job summaries of the workflow run. Rerun a case locally with |
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.
Summary
#573: object-stream members are looked up by object number, not by xref index.
bug1978317has an object stream with 65,542 members, but its xref stream uses/W [1 3 2]. The 2-byte in-stream index wraps above 65535, so the catalog's index 65541 became 5. The loader matched members by that index and stored whatever object sat there (an annotation) as the catalog, so/Pageswas missing.The object stream's header already names every member's object number, so it is now the only authority:
BTreeSet<usize>);CompressedObjectdiagnostic, instead of receiving a wrong object (this matches PDFium);CrossReferenceEntryType::Compressed, since nothing reads it any more. The xref-stream parser still steps over the field.#605: page-tree nodes without
/Type.A
/Kidsentry with no/Typeis now a branch when it has/Kidsand a page otherwise, as PDFium and pdf.js do, instead of failing the read.Verification
cargo test -p pdf-document -p pdf-parser -p pdf-object-reader, workspaceclippy -D warningsandcargo fmt --checkall pass. No new tests were added; existing assertions on the removed index were updated.cargo conformance verify conf2-d93ae0eb85b4exits 0.cargo conformance verify conf2-3de5eaa05167 --allow-differentexits 0.issue9105_othernow reads but fails differently at render (invalid page bounds), because its page has no MediaBox andPdfPage::page_size()returnsNone. That is a separate cause and is left for a follow-up.document_openbench, 5 interleaved A/B rounds againstmain: −0.3% to +2.4%. None of the bench PDFs contains an object stream, so the changed path is not exercised and these numbers are noise.Fixes #573
Fixes #605
🤖 Generated with Claude Code