v157 · sanitizer api · basic / canonical

javascript: URL playground

One input, four real call shapes. The markup below goes through the actual Sanitizer API in your browser — no simulation — and the page diffs which javascript: navigation URLs survived. The interesting row is the third one: setHTMLUnsafe() with javascriptURLs: false is the configuration that was impossible to express before Chrome 157.

Probing this browser…

Run the sanitizer

Call shape

Not run yet.

the code

// The newly expressible configuration: keep what the unsafe path keeps
// (comments, data-*, <script> elements as inert markup) but still strip
// javascript: navigation URLs.
el.setHTMLUnsafe(untrusted, { sanitizer: { javascriptURLs: false } });

// Safe calls are unaffected: removeUnsafe() forces javascriptURLs to false,
// so this still strips them despite the explicit true:
el.setHTML(untrusted, { sanitizer: { javascriptURLs: true } });

see also