Skip to content

3.0: refuse input and files that do not comply with the ISO PDF rules #614

Open

Description

@Tim81

Maintainer decision, 2026-11-18: "Version 3.0 should be very strict." Input and files that do not
comply with the ISO PDF rules are refused. This issue is the umbrella for that rule. It does not
replace the issues below; it says what each one covers and what is left over.

Why

The maintainer gave two reasons on 2026-11-18:

  • Strict output: what the library writes complies with the ISO rules.
  • A smaller attack surface on the read side. A reader that refuses non-compliant files by default
    does not run its tolerance paths on hostile input unless the caller opts into repair.

#610 is the measured example of what a tolerance path costs on crafted input. On origin/main
1c61fa6, PdfReader.Open with AllowReconstruction = true on a 4 KiB run of [ allocated
293,244,376 bytes, against 952 bytes with reconstruction off. Both calls threw
InvalidDataException. That is one input on one path; it is not a measurement of the security
benefit of a strict default.

The rule

Refuse at the earliest point the library can name the defect:

Where What is checked When it throws
Writer input A value or combination a caller sets that the rules do not allow At the call or property that takes it, not at the later Save
Written output A document that would claim or contain something it does not meet At Save, before anything is written to the stream
Read files A file that does not comply At Open, naming the clause

The 2.x line, so 3.0 has something to turn on

2.x follows "valid file = keep" (#484's contract): any input for which 2.x writes a valid PDF keeps
saving, even when content is lost or misplaced. Three examples from PR #571's review, measured on
main 1c61fa6 (2.3.3 plus dependency updates): a table with an infinite top margin is not drawn, text
runs below the page when the available height is infinite, and a JBIG2 image with an unknown-length
segment embeds blank.

Each such kept input carries a "Do not pass ..." XML-doc paragraph that names 3.0. That paragraph is
the marker this issue collects. In 3.0 each one becomes a refusal.

How the related issues fit

The bridge through #607

  1. Every input that 2.x keeps under "valid file = keep" gets its own diagnostic code in v2.4.
  2. Strict mode (opt-in in 2.x) refuses each of those codes.
  3. In 3.0 strict becomes the only behaviour, so the switch goes away and every code is a refusal.

What "ISO PDF rules" means here

This says which standards bind which check. It adds no profile that #474 does not already name.

The Reader decision

In 3.0 the Reader is strict by default:

  • Open refuses a file that does not comply and names the clause.
  • AllowReconstruction and similar repair options remain explicit opt-ins.
  • A result that was repaired is reported as non-compliant, so a caller cannot take a repaired
    document for a compliant one.

A strict default would refuse the [ file from #610 before reconstruction runs. A caller who opts
into AllowReconstruction still reaches the tolerance path, so it must stay bounded. #610 (v2.4)
is the issue for that.

The Reader package is still Preview and unshipped until #187 graduates it, so its surface can move
to carry this.

Open design questions

Not decided here:

  • The exception type: one type for every refusal, or a hierarchy by where it is raised.
  • How a clause is named: a structured property (standard, clause) alongside the message, or the
    message alone.
  • How Conformance: a PDF/A or PDF/UA claim is stamped on a document the library's own preflight rejects #474's need to demonstrate a failing preflight verdict is met once Save refuses a failing
    claim.
  • Whether a refusal at the property is possible everywhere, or whether some combinations can only be
    checked at Save.
  • What the Reader's "non-compliant" report looks like on a repaired result.

Acceptance

  • Every "Do not pass ... 3.0" paragraph in src becomes a refusal with a test that asserts the
    exception and its message, not only that something threw. The sweep greps the XML docs of all
    eight packages.
  • Each diagnostic code added under Layout: one general diagnostics channel and an opt-in strict mode (the additive half of #496 and the channel of #304) #607 maps to one refusal, with a test.
  • Reader refusals name the clause, with a test per refusal.
  • The opt-in repair path reports non-compliance on its result, with a test.
  • PublicAPI.Unshipped.txt and the XML docs of each touched member are updated in the same commit,
    per CLAUDE.md.

Activity

  1. added
    enhancement
    type/tracking
    needs-design
    on Nov 18, 2026
  2. Tim81 commented on Nov 18, 2026

    @Tim81
    OwnerAuthor

    Decided 2026-11-18 by the maintainer for the #474 showcase question above: preflight without a claim. In 3.0 the showcase keeps demonstrating a failing verdict by saving the document without the PDF/A or PDF/UA claim (or validating it in memory) and running PdfPreflight against the target profile, so no file is written that claims a conformance it fails. Save refuses a failing claim with no opt-out.

    The exception design (one type or a hierarchy, and how the clause is named) stays open until the 3.0 design work starts.

  3. Tim81 commented on Nov 27, 2026

    @Tim81
    OwnerAuthor

    The v2.4 slice for language values is #749: under PDF/A-2a and PDF/UA-1, Layout reports a value that is not a language tag as an Error so strict mode refuses; the default refusal stays here for 3.0.

  4. Tim81 commented on Nov 29, 2026

    @Tim81
    OwnerAuthor

    The ISO audit (docs/conformance-v2.4.md) has skipped tests that wait on this issue; the fix removes their skip and makes them pass.

    • Iso14289_1_7_2_LanguageThatIsNotATagIsNotWrittenUnderPdfUA1 (group G5)
    • Iso19005_2_6_7_4_LanguageThatIsNotATagIsNotWrittenUnderPdfA2a (group G5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-designtype/tracking

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions