Skip to content

feat(edit): fail-closed validation before Edit PDF publish (#34) - #54

Open
nonamexishere wants to merge 2 commits into
McanKul:developmentfrom
nonamexishere:feat/34-validate-edit-output
Open

feat(edit): fail-closed validation before Edit PDF publish (#34)#54
nonamexishere wants to merge 2 commits into
McanKul:developmentfrom
nonamexishere:feat/34-validate-edit-output

Conversation

@nonamexishere

Copy link
Copy Markdown
Contributor

Summary

Adds a fail-closed publish gate for Edit PDF (#34). After qpdf writes the dest-sibling temp file, and before the atomic rename onto the chosen destination, OffPDF now:

  • runs qpdf --check (exit 2 = fatal, exit 3 = warning recorded and does not block, exit 0 = clean)
  • reopens the staged PDF and checks page count/order, MediaBox / CropBox / TrimBox, /Rotate, /UserUnit
  • requires Outlines, Info, AcroForm, and page annotations when the source had them

A failed gate returns INVALID_OUTPUT, deletes the staging file, and leaves the original and any existing destination untouched. The gate is validate_staged_pdf so later annotation / form / redaction work can reuse it.

Packaged Save uses the same bundled qpdf binary as overlay (resolve_qpdf(app)).

Why

Epic #12’s definition of done calls for output validation before any existing-content mutation ships. Today a damaged overlay result could still replace the destination.

Validation

  • npm run typecheck
  • npm test (179)
  • cargo check --manifest-path src-tauri/Cargo.toml
  • cargo test --manifest-path src-tauri/Cargo.toml --lib (109)
  • Manual Save on Edit PDF (new dest; original unchanged)

Privacy Checklist

  • This keeps OffPDF usable offline.
  • This does not upload, log, or transmit user files.
  • New dependencies or bundled binaries have compatible licenses.

Validate staged Edit PDF output before the destination rename so a
truncated or structurally wrong file cannot replace the user's dest.
qpdf --check errors are fatal; warnings are recorded and do not block.
Fixes McanKul#34.
@nonamexishere
nonamexishere force-pushed the feat/34-validate-edit-output branch from 660d77d to ae51a6e Compare August 24, 2026 13:49
Re-check cancel after qpdf --check and before publish so a mid-gate
Cancel returns CANCELLED, deletes staging, and does not replace dest.
Production --check registers on the job handle like overlay qpdf.
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