Skip to content

feat!: refuse the PDF features a scanned book never has - #8

Merged
stephen-masters merged 2 commits into
mainfrom
feat/pdf-features
Nov 1, 2026
Merged

stephen-masters merged 2 commits into
mainfrom
feat/pdf-features

Conversation

@stephen-masters

Copy link
Copy Markdown
Contributor

Summary

  • A new policy field, pdf_features, naming which of JavaScript, forms, attached files and launch actions a PDF may carry. The default and STRICT allow none: each is a way for a document to make the viewer act rather than draw the page, and a scanned book has none. --pdf-features does the same for the command, and Facts.features says what was found.
  • How each is found. JavaScript and forms from pdfinfo's own report (JavaScript: yes, Form: AcroForm), attached files from pdfdetach -list, both of which see inside compressed object streams. A launch action is reported by no poppler tool, so it is found by its name in the bytes with #xx escapes undone, the way pdfid does it: a bounded search in 1 MiB chunks, not a parser. AGENTS.md records that exception to the "no PDF code here" rule and that it must stay a search.
  • Attached files and the launch scan only run when the page count is within the limit; a file over it is refused whatever else it carries.
  • README: a policy table row, the "what it does" step, the command's option list and an example line. PdfInfoMissing now names whichever poppler tool is absent.

Breaking: a PDF carrying any of the four passed before and is refused by default now, so this is a feat! under the release rule. Stage 2 of brief 022.

Test plan

  • Hostile corpus: a PDF with each feature, plus the #-escaped spellings of the JavaScript and Launch names; each refused with its sentence, each passed when the policy names it; a policy that allows some names them in the reason; a PDF over the page limit still reports what the summary showed
  • The launch scan: escaped spellings, /Launcher and /Launch2 not matched, a name straddling a chunk boundary
  • pdfdetach missing is a configuration error naming the tool
  • ruff, ruff format, mypy strict, 374 tests, coverage 98%, uv lock --check, zensical build --clean --strict
  • All 20 real PDFs in the Tetrak checkouts (the evaluation corpus and the workspace, including a searchable PDF) still pass

🤖 Generated with Claude Code

stephen-masters and others added 2 commits November 1, 2026 21:36
JavaScript, a form, attached files and a launch action are each a way for
a document to make the viewer act rather than draw the page, and none of
them belongs in a scan. The default policy now refuses all four, and
`pdf_features` names the ones a policy will pass; `--pdf-features` does
the same for the command. The verdict's facts carry what was found.

JavaScript and forms are read from pdfinfo's report and attached files
from pdfdetach's listing, so a feature inside a compressed object stream
is still seen. A launch action is reported by no poppler tool, so it is
found by its name in the file, the way pdfid finds it: a bounded scan of
the bytes with the #xx escapes undone, which is a search and not a
parser; AGENTS.md says so and says it must stay that way. Attached files
and the scan are only looked for when the page count is within the
limit, since a file over it is refused whatever else it carries.

Breaking: a PDF that carries any of the four, which passed before, is
refused by default. The hostile corpus gains a PDF for each, including
the escaped spellings. Stage 2 of brief 022.

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…es not report an open action's script

CI's poppler, 24.02, says `JavaScript: no` for a script attached to the
document's open action; 26.04 says yes. The report is still read, and
the same bounded scan that finds a launch action now finds the names
/JavaScript and /JS as well. The corpus gains a document-level script,
which every poppler reports, and a test fakes the older report.

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@stephen-masters
stephen-masters merged commit 9566285 into main Nov 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant