#2194
fix(policy): require evaluate for javascript: URL navigation
Fixes #2172
A daemon navigate request with a javascript: URL runs script in the current page, but the action policy only checks navigate. With "deny": ["evaluate"], eval is denied while navigate to javascript:document.title='x' still changes the page.
Changes
policy_actions_for_commandaddsevaluateto the checked policy actions whennavigate,tab_new,a11y, orvitalsreceives a URL whose scheme isjavascript. This follows the existing pattern that addsnavigatefora11y <url>.- The scheme check uses
url::Url::parse, so mixed case and leading whitespace (" JavaScript:...") are covered the same way Chrome parses them. - Other URLs are unchanged:
https://example.com/javascript:still checks onlynavigate.
Tests
- New unit test
test_javascript_url_policy_actions_include_evaluatecovers all four actions with lowercase and mixed-case/whitespacejavascript:URLs, plus anhttpsURL that must not requireevaluate. cd cli && cargo test --bin agent-browser javascript_url_policy: fails without the change, passes with it.cargo fmt -- --checkandcargo clippyare clean.
@RaphaelFakhri is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.