Skip to content

Sanitizer: add javascriptURLs option to SanitizerConfig and Sanitizer - #12898

Merged
annevk merged 3 commits into
mainfrom
js-url-in-policy
Sep 4, 2026
Merged

Sanitizer: add javascriptURLs option to SanitizerConfig and Sanitizer#12898
annevk merged 3 commits into
mainfrom
js-url-in-policy

Conversation

@noamr

@noamr noamr commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Instead of the "remove JS URLs" directive rely solely on the method being "Safe", keep it in the configuration.
That makes it apply also in the removeUnsafe() case.

It follows the exact same logic as data attributes and comments.

Closes #12686

(See WHATWG Working Mode: Changes for more details.)

Comment thread source Outdated

<li><p>If <var>configuration</var>["<code
data-x="dom-SanitizerConfig-javascriptURLs">javascriptURLs</code>"] does not <span data-x="map
exists">exist</span>, then set it to <var>allowCommentsPIsAndDataAttributes</var>.</p></li>

@annevk annevk Sep 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should rename the variable. Perhaps allowBooleanMembers? cc @evilpie

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

permissiveDefaults ?

@noamr noamr Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that this also affects the default PI handling which is not boolean...
I'd suggest <var>defaults</var> which can be "permissive" or "restrictive" ?

permissiveDefaults if we want to simplify

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That all sounds fine to me, even just permissive might work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, changed to permissiveDefaults

Comment thread source Outdated
data-x="dom-SanitizerConfig-valid">valid</span>.</p></li>

<li><p>If <var>configuration</var>["<code
data-x="dom-SanitizerConfig-javascriptURLs">javascriptURLs</code>"] <span data-x="map

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is an issue with e.g. setComments as well, but doesn't javascriptURLs always exist after canonicalizing a SanitizerConfig?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in both places

@evilpie

evilpie commented Sep 4, 2026

Copy link
Copy Markdown
Member

Otherwise this looks good to me.

@annevk
annevk merged commit e5071a2 into main Sep 4, 2026
2 checks passed
@annevk
annevk deleted the js-url-in-policy branch September 4, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Sanitizer] Should JS URL attribute removal be part of the configuration?

3 participants