#[non_exhaustive]pub enum TerminatorPolicy {
Strict,
RecoverAtNextHeader,
}Expand description
What to do when an indirect object’s endobj keyword is missing.
§7.3.10 requires a definition to be N G obj … endobj, so a body that
runs straight into the next N G obj header is malformed. But the
object itself may have parsed perfectly — the damage is a missing
four-byte keyword, not a corrupt value — and refusing it costs the
operator the whole object.
The default is and must stay TerminatorPolicy::Strict, for the
same reason StreamLengthPolicy::Strict is: on a cleanly-loading
file a missing endobj is real damage the operator should hear about,
and accepting it would put an inferred extent into the writer’s
byte-identical re-emission path and break the round-trip/minimal-diff
invariant (ARCHITECTURE.md §5).
§Why the lenient policy exists
It was added 2026-08-07 after the veraPDF parse gate found pdfcer
writing a document whose catalog said /Pages 2 0 R while object 2
was absent from the file. The input (qpdf’s bad6.pdf) omits
exactly one endobj — the one after the /Pages node — so
confirm_candidates dropped the object as unparseable and the writer
emitted a catalog pointing at nothing. veraPDF could recover the
original and could not recover pdfcer’s rewrite of it, which is a
document made strictly worse by passing through pdfcer.
Like StreamLengthPolicy::RecoverFromEndstream, this is reachable
only from the rebuild-by-scan recovery path, where the file’s
cross-reference machinery has already been proven unparseable and no
byte-identical re-emission is on the table.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Strict
A missing endobj is ParseErrorKind::MissingEndobj. The
default, and the only policy the clean load path ever uses.
RecoverAtNextHeader
Accept a definition whose body parsed cleanly but whose endobj is
missing, provided the terminator looks like the start of the next
object header (an integer) or the buffer ended.
The integer guard is what keeps this from swallowing arbitrary
garbage: 2 0 obj << … >> 3 0 obj recovers, while a body followed
by an unexpected keyword still fails. Every such repair is counted
in Parser::missing_endobj_recovered so it can be disclosed
(R20, fuzzy-never-sneaky) rather than silently absorbed.