Repository navigation
Resolve references to missing objects as null in the object reader - #568
Merged
Merged
Conversation
ISO 32000 §7.3.10 treats a reference to a nonexistent object as null, but the reader raised MissingObject. Decoders worked around it one by one with is_absent checks, and every other optional read failed instead of yielding None. The reader now resolves an absent object to null and MissingObject is removed. ObjectCollection::insert decodes stream filters while objects are still loading, where a missing object may be defined later, so it reads through a source that fails on unloaded objects and keeps such streams encoded as before. The /Contents and /Annots workarounds are removed and is_absent becomes a plain null check. 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 corpus1008 documents compared with Regressions
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
ISO 32000 §7.3.10 treats a reference to a nonexistent object as null. The object reader raised
MissingObjectinstead. Decoders worked around that one by one withis_absentchecks, for page/Contentsand/Annotsamong others. Every otheroptionalread failed outright instead of returningNone.ReadSession::load_objectresolves an absent object toNull.ObjectReadError::MissingObjectis removed.optional/optional_sharednow returnNonefor these references through the existingOption<T>null handling.ObjectCollection::insertdecodes stream filters while objects are still loading, where a missing object may be defined later. It now reads through a privateLoadedObjectssource that fails on unloaded objects, so those streams stay encoded and are decoded later, as before./Contentsand/Annotsworkarounds are gone, andis_absentis now a plain null check.Required reads of a missing object still fail, now with a
TypeMismatchthat reportsNull. Some documents that failed to read before may now read; the conformance comment on this PR will show any changes.Test plan
cargo fmt --check,cargo clippy --all --workspacecargo test --workspace(Skia crates excluded locally); includesinsert_preserves_encoded_state_when_filter_dependencies_are_unresolved🤖 Generated with Claude Code