Skip to content

fix(inspect): report /OpenAction JavaScript in document info - #2687

Merged
aiongg merged 2 commits into
storytold:mainfrom
charan-rathore:fix/inspect-openaction-javascript
Oct 18, 2026
Merged

aiongg merged 2 commits into
storytold:mainfrom
charan-rathore:fix/inspect-openaction-javascript

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

A catalog /OpenAction with /S /JavaScript is the standard way a PDF runs JavaScript on open. The info command's javascript flag covered form field actions, the Names/JavaScript name tree, and link annotations, but never looked at /OpenAction, so a document that executes JS on open reported javascript: false.

The fix resolves /OpenAction after the Names check in crates/render/src/inspect.rs and sets has_javascript when the action is /S /JavaScript. Destination-style /OpenAction values (arrays, /GoTo actions) stay false, covered by a new control test.

Tests: two new cases in inspect.rs (JS OpenAction sets the flag, /GoTo OpenAction does not). cargo fmt --check, cargo clippy -p pdfcraft-render --all-targets -- -D warnings, cargo test -p pdfcraft-render (298 passed), and cargo xtask layers are all green.

Closes item 9 of #2670.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: pass
  • cargo test --locked -p pdfcraft-render --lib open_action: 2 passed, 0 failed
  • cargo 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: clean
  • cargo check --locked -p pdfcraft-render --target wasm32-unknown-unknown: pass
  • cargo xtask layers: pass
  • Red check: with only the 6 added production lines removed and the tests kept, open_action_javascript_sets_has_javascript fails (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.

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.

3 participants