Repository navigation
fix(inspect): report /OpenAction JavaScript in document info - #2687
Conversation
FredApps
left a comment
There was a problem hiding this comment.
Reviewed at head b4af74d. Approving.
Code: the new check in crates/render/src/inspect.rs resolves /OpenAction through the existing self.dict (which handles indirect references and returns None for arrays/destinations) and compares /S to JavaScript via fallible calls only. No unwrap, no indexing on input. A destination-array or /GoTo OpenAction leaves the flag false. Scope is limited to the one flag plus tests.
Validated on a Linux validation host (detached worktree of the PR head, source hashes identical before and after):
cargo fmt --all -- --check: passcargo test --locked -p pdfcraft-render --lib open_action: 2 passed, 0 failedcargo test --locked -p pdfcraft-render --lib inspect: 61 passed, 0 failed (this is the inspect module only, not the whole crate)cargo clippy --locked -p pdfcraft-render --all-targets -- -D warnings: cleancargo check --locked -p pdfcraft-render --target wasm32-unknown-unknown: passcargo xtask layers: pass- Red check: with only the 6 added production lines removed and the tests kept,
open_action_javascript_sets_has_javascriptfails (crates/render/src/inspect.rs:3021) while the GoTo control test still passes.
Not verified: the full pdfcraft-render test suite (the PR description cites 298 passed; I ran the filtered subsets above), GitHub-hosted CI checks, macOS/native builds.
Non-blocking: a JavaScript action reached only through /OpenAction /Next chains is not detected; reasonable to leave for a follow-up.
A catalog
/OpenActionwith/S /JavaScriptis the standard way a PDF runs JavaScript on open. Theinfocommand'sjavascriptflag covered form field actions, theNames/JavaScriptname tree, and link annotations, but never looked at/OpenAction, so a document that executes JS on open reportedjavascript: false.The fix resolves
/OpenActionafter theNamescheck incrates/render/src/inspect.rsand setshas_javascriptwhen the action is/S /JavaScript. Destination-style/OpenActionvalues (arrays,/GoToactions) stay false, covered by a new control test.Tests: two new cases in
inspect.rs(JS OpenAction sets the flag,/GoToOpenAction does not).cargo fmt --check,cargo clippy -p pdfcraft-render --all-targets -- -D warnings,cargo test -p pdfcraft-render(298 passed), andcargo xtask layersare all green.Closes item 9 of #2670.