Skip to content

Enable createParserOptions, passing a sanitizer to trusted types - #606

Merged
noamr merged 65 commits into
mainfrom
create-parser-options
Oct 7, 2026
Merged

noamr merged 65 commits into
mainfrom
create-parser-options

Conversation

@noamr

@noamr noamr commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

createParserOptions receives an optional SetHTMLUnsafeOptions dictionary (or ParseHTMLUnsafeOptions) and turns it into a TrustedHTMLParserOptions object using the createParserOptions method defined on the policy.

  • createParserOptions serves as the primary Trusted Types mechanism for HTML fragment parsing sinks (setHTMLUnsafe, innerHTML, outerHTML, insertAdjacentHTML, and createContextualFragment), allowing a policy to configure a Sanitizer, and allow/disallow script execution:

  • Passing a TrustedHTMLParserOptions object directly into a fragment parsing sink satisfies Trusted Types enforcement for HTML documents, allowing raw markup strings to be parsed without requiring a TrustedHTML object or invoking createHTML.

  • When a default policy defines createParserOptions, calls to fragment parsing sinks automatically produce a TrustedHTMLParserOptions that satisfies the sink, applying the policy's sanitizer and script-execution settings. Note that the default policy takes precedence even if less restrictive than the caller - it can vet a less restrictive sanitizer, or enable script execution.

  • If no TrustedHTMLParserOptions is provided (either by the caller or via a default policy's createParserOptions), we fall back to the existing get trusted type compliant string, requiring input to be a TrustedHTML or passing it to the default policy's createHTML. This ensures backwards compatibility for policies that only define createHTML, and covers string-only sinks that do not support parser options (e.g. document.write(), XML documents, and iframe.srcdoc). Note that TrustedHTML does not receive special handling when createParserOptions is present in the policy - in supported browsers/sinks, createHTML and TrustedHTML are a fallback only.

  • For sinks where the full HTML is not available up front (such as streaming parsing), get trusted type compliant parser options is invoked with throwIfMissing = true, requiring the caller to supply a TrustedHTMLParserOptions or requiring the default policy to define createParserOptions.

  • When TrustedHTML is provided together with author-specified runScripts or sanitizer, an exception is throws - as this can lead to an insecure blend, see Evaluate createHTML interaction with sanitizer replaceWithChildren (and runScripts?) #615. This includes explicitly passing "default" to setHTMLUnsafe (this can be relaxed later on).

  • TrustedHTMLParserOptions` does not expose any interface methods or attributes to JavaScript; it acts as an immutable, opaque token whose internal associated configuration and script-execution settings are inspected directly by specification algorithms.

  • report-only mode might report twice if both createParserOptions and createHTML violate the policy.

  • Security model: As documented in the Security Considerations, a createParserOptions callback that does not configure a sanitizer to remove unsafe markup (e.g. scripts or event handlers) grants a pass-through to parse arbitrary markup without DOM XSS protection. It is the responsibility of the policy author / security auditor to ensure createParserOptions enforces adequate sanitization, or that a TrustedHTMLParserOptions object is only passed to trusted source (similar to the policy objects themselves).

As a followup, we should evaluate the (existing) combination of TrustedHTML with sanitizer. Opened #615 for that.

This is the trusted-types part of #594 together with whatwg/html#12583.
Note that this should only be merged when wired into the HTML standard, once the sanitizer is itself upstreamed.


Preview | Diff

@noamr
noamr requested a review from lukewarlow February 17, 2026 11:13
@noamr noamr mentioned this pull request Feb 17, 2026
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
@lukewarlow

Copy link
Copy Markdown
Member

LGTM

@kkoyung kkoyung mentioned this pull request May 28, 2026
24 tasks done
@noamr
noamr force-pushed the create-parser-options branch from ced3862 to d44dcea Compare June 1, 2026 13:44
@noamr

noamr commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

I've made some changes:

  • Some of the algorithm calls from "get Trusted Type compliant parser options" assumed stringifications. Made that algorithm do things on its own and passing a new object (repersented as an ordered map) instead.
  • Allow passing throwIfMissing from the outside. streamHTMLUnsafe methods should throw if the policy cannot create parser options, while setHTMLUnsafe and friends can rely on createHTML.
  • Support runScripts as per Add runScripts to SetHTMLUnsafeOptions whatwg/html#12495

(Note: this PR will fail build until we merge the latter)

@lukewarlow

Copy link
Copy Markdown
Member

Are you able to fix the build failure now?

@noamr noamr closed this Jun 9, 2026
@noamr noamr reopened this Jun 9, 2026
@noamr

noamr commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Are you able to fix the build failure now?

I'll revisit this once I have the HTML counterpart ready.

Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
Comment thread spec/index.bs Resolved
@annevk

annevk commented Jun 22, 2026

Copy link
Copy Markdown
Member

Also, reportedly this impacts innerHTML and friends as well somehow? I think that warrants some examples.

@noamr

noamr commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Also, reportedly this impacts innerHTML and friends as well somehow? I think that warrants some examples.

Added prose and examples for this

@noamr

noamr commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

(The build failure is in main, trying to resolve separately. Do you have an idea maybe @lukewarlow ?)

@evilpie

evilpie commented Jun 23, 2026

Copy link
Copy Markdown

In TrustedParserOptions sanitizer member is readonly, but a Sanitizer instance allows for internal modification. Isn't that unexpected?

Also I feel like we should probably always return a Sanitizer object, instead of one of three options? Otherwise it seems easy to accidentally write code (not sure what for though?) that only works with a subset.

@noamr

noamr commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

In TrustedParserOptions sanitizer member is readonly, but a Sanitizer instance allows for internal modification. Isn't that unexpected?

It's a good point. I guess we need to return a clone of the underlying sanitizer if the getter is invoked so that you couldn't get a TrustedParserOptions and then mutate it.

Also I feel like we should probably always return a Sanitizer object, instead of one of three options? Otherwise it seems easy to accidentally write code (not sure what for though?) that only works with a subset.

Yea I was contemplating that. SGTM

noamr and others added 12 commits June 23, 2026 13:32
`createParserOptions` receives a `SetHTML{Unsafe}Options` and turns them into
a `TrustedParserOptions` using the given method from the policy config.

This is the `trusted-types` part of #594
(Need to wire it to HTML as well)
Co-authored-by: Anne van Kesteren <[email protected]>
Co-authored-by: Anne van Kesteren <[email protected]>
Co-authored-by: Anne van Kesteren <[email protected]>
* Reject `TrustedHTML` with an unvetted sanitizer or `runScripts`

Without a `TrustedHTMLParserOptions` or a default policy's `createParserOptions`, a caller-supplied `sanitizer` or `runScripts: true` could make vetted markup unsafe.

Fixes #615.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Check unvetted options in parser options and ignore empty `sanitizer`

An empty `sanitizer` is the IDL default, so it counts as no sanitizer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Don't reject `runScripts` without a parser policy

`createContextualFragment` sets `runScripts` to true, so rejecting it would break `TrustedHTML` there.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

* Reject author-supplied `runScripts` without a parser policy

Sinks that construct their own options, like `createContextualFragment`, pass false for the new `optionsFromAuthor` argument.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@zcorpan

zcorpan commented Oct 2, 2026

Copy link
Copy Markdown
Contributor
AI review

Line numbers are spec/index.bs at f9556e5.

  • index.bs:1457-1462 (XML): "get trusted type compliant input" calls createParserOptions before checking documentType, then ignores the result for XML. So in an XML document, innerHTML, outerHTML, insertAdjacentHTML and createContextualFragment still invoke the default policy's createParserOptions. If the callback throws or returns null, the call fails even though the options are never used. Chromium CL 8496967 skips createParserOptions for XML documents instead (trusted_types_util.cc, !is_xml_document &&). Maybe only call it when documentType is "html".
  • index.bs:1395 vs 1530-1535 (callback argument shape): policy.createParserOptions(options) hands the callback the author's dictionary unchanged, so sanitizer can be a SanitizerConfig, "default" or a Sanitizer. The default-policy path always wraps it in a Sanitizer. The spec's own examples (703, 1160) call options.sanitizer?.get(), which throws for policy.createParserOptions({sanitizer: {elements: ["b"]}}). Maybe normalize it to a Sanitizer in both paths.
  • index.bs:703-704 (example): new Sanitizer({}) plus removeElement("script") still keeps event handler attributes. Since the section is about enforcing the sanitizer, maybe use removeUnsafe().
  • index.bs:1559 (stale note): it says an empty SanitizerConfig is the default for SetHTMLUnsafeOptions.sanitizer, but html#12583 removes that = {} default.
  • index.bs:1556 (vetting): sanitizer: "default" counts as needing vetting, so setHTMLUnsafe(trustedHTML, {sanitizer: "default"}) throws without a createParserOptions default policy. The preset can only make the markup safer, so maybe exempt it. This is a question, not a bug.
  • index.bs:1531-1535 (redundant step): it builds a Sanitizer and configures it, and the copy step already did the same. A single Sanitizer from the copy step would do.

@noamr

noamr commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Line numbers are spec/index.bs at f9556e5.

  • index.bs:1457-1462 (XML): "get trusted type compliant input" calls createParserOptions before checking documentType, then ignores the result for XML. So in an XML document, innerHTML, outerHTML, insertAdjacentHTML and createContextualFragment still invoke the default policy's createParserOptions. If the callback throws or returns null, the call fails even though the options are never used. Chromium CL 8496967 skips createParserOptions for XML documents instead (trusted_types_util.cc, !is_xml_document &&). Maybe only call it when documentType is "html".
  • index.bs:1395 vs 1530-1535 (callback argument shape): policy.createParserOptions(options) hands the callback the author's dictionary unchanged, so sanitizer can be a SanitizerConfig, "default" or a Sanitizer. The default-policy path always wraps it in a Sanitizer. The spec's own examples (703, 1160) call options.sanitizer?.get(), which throws for policy.createParserOptions({sanitizer: {elements: ["b"]}}). Maybe normalize it to a Sanitizer in both paths.
  • index.bs:703-704 (example): new Sanitizer({}) plus removeElement("script") still keeps event handler attributes. Since the section is about enforcing the sanitizer, maybe use removeUnsafe().
  • index.bs:1559 (stale note): it says an empty SanitizerConfig is the default for SetHTMLUnsafeOptions.sanitizer, but html#12583 removes that = {} default.
  • index.bs:1556 (vetting): sanitizer: "default" counts as needing vetting, so setHTMLUnsafe(trustedHTML, {sanitizer: "default"}) throws without a createParserOptions default policy. The preset can only make the markup safer, so maybe exempt it. This is a question, not a bug.
  • index.bs:1531-1535 (redundant step): it builds a Sanitizer and configures it, and the copy step already did the same. A single Sanitizer from the copy step would do.

All addressed.
For now, the default config does need vetting (but not an empty config).
That's because using "default" in an *Unsafe method is a user choice.
We can maybe start with this as a default and relax later if it seems reasonable to?

beckysiegel pushed a commit to chromium/chromium that referenced this pull request Oct 6, 2026
This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2026
This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 6, 2026
This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}
@annevk

annevk commented Oct 7, 2026

Copy link
Copy Markdown
Member
AI feedback

Reviewed at c5aa609, together with whatwg/html#12583.

Suggestions

  • get trusted type compliant parser options, null/undefined branch: in report-only mode, a null result returns the original options. get trusted type compliant input then falls through to get trusted type compliant string, so a default policy's createHTML also runs and a second violation is reported for the same call. The same happens on the "no policy, options need vetting" path. Either skip the string check after a report-only "Allowed" disposition, or note that the double invocation and report are intended.
  • needs vetting: any sanitizer other than an empty SanitizerConfig needs vetting, including "default" and a Sanitizer with a safe configuration. With enforcement and no createParserOptions, setHTMLUnsafe(trustedHTML, { sanitizer: "default" }) used to work and now throws a TypeError. The built-in safe default configuration cannot make vetted markup unsafe; the risky cases are things like replaceWithChildrenElements. Consider exempting "default", or confirm the change is intended and covered by tests.
  • get trusted type policy value and get trusted type compliant parser options both build the same «[ "runScripts" → …, "sanitizer" → … ]» argument inline. Consider factoring this into a shared helper.

Nits

  • create a trusted type: "If |policyValue| is not a dictionary" can only mean null, given the callback's return type. Consider "is null". It may also be worth noting that a named policy returning null throws here, whereas createHTML returning null yields the empty string.

@noamr

noamr commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

AI feedback
Reviewed at c5aa609, together with whatwg/html#12583.

Suggestions

  • get trusted type compliant parser options, null/undefined branch: in report-only mode, a null result returns the original options. get trusted type compliant input then falls through to get trusted type compliant string, so a default policy's createHTML also runs and a second violation is reported for the same call. The same happens on the "no policy, options need vetting" path. Either skip the string check after a report-only "Allowed" disposition, or note that the double invocation and report are intended.

Added a note in the OP

  • needs vetting: any sanitizer other than an empty SanitizerConfig needs vetting, including "default" and a Sanitizer with a safe configuration. With enforcement and no createParserOptions, setHTMLUnsafe(trustedHTML, { sanitizer: "default" }) used to work and now throws a TypeError. The built-in safe default configuration cannot make vetted markup unsafe; the risky cases are things like replaceWithChildrenElements. Consider exempting "default", or confirm the change is intended and covered by tests.

Added a note in the OP. Will make sure that it's covered in the WPT PR.

  • get trusted type policy value and get trusted type compliant parser options both build the same «[ "runScripts" → …, "sanitizer" → … ]» argument inline. Consider factoring this into a shared helper.

Done

Nits

  • create a trusted type: "If |policyValue| is not a dictionary" can only mean null, given the callback's return type. Consider "is null". It may also be worth noting that a named policy returning null throws here, whereas createHTML returning null yields the empty string.

Done

@noamr
noamr merged commit fbe9462 into main Oct 7, 2026
3 checks passed
github-actions Bot added a commit that referenced this pull request Oct 7, 2026
SHA: fbe9462
Reason: push, by noamr

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
zcorpan added a commit to whatwg/html that referenced this pull request Oct 7, 2026
Fragment parsing sinks now call "get trusted type compliant input" instead of "get trusted type compliant string". This lets a default policy's `createParserOptions` supply a sanitizer or change script-running behavior for `innerHTML`, `outerHTML`, `insertAdjacentHTML()`, `createContextualFragment()`, `setHTMLUnsafe()`, and `parseHTMLUnsafe()`. This only applies in HTML documents. `srcdoc`, `document.write()`, `DOMParser`'s `parseFromString()`, and `execCommand("insertHTML")` are unchanged for now.

The fragment parsing algorithm steps now take a single mode (safe, unsafe, or legacy) instead of a safe boolean and a scripting mode. They also handle sanitization for all of these sinks.

This also removes the `{}` default from the `sanitizer` member of `SetHTMLUnsafeOptions` and `ParseHTMLUnsafeOptions`. `setHTML()` and `parseHTML()` no longer mutate a passed `Sanitizer`, and configuring a sanitizer no longer mutates the built-in safe default configuration. `createContextualFragment()` now creates its fallback `body` in the node document of the range's start node.

Goes with w3c/trusted-types#606.

Co-authored-by: Simon Pieters <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
@annevk
annevk deleted the create-parser-options branch October 7, 2026 12:41
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Oct 10, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 13, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Commit-Queue: Noam Rosenthal <nrosenthalgoogle.com>
Cr-Commit-Position: refs/heads/main{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321

UltraBlame original commit: a158e7688437ddc49df990c7863dd38fbf1ffd0d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 13, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Commit-Queue: Noam Rosenthal <nrosenthalgoogle.com>
Cr-Commit-Position: refs/heads/main{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321

UltraBlame original commit: a158e7688437ddc49df990c7863dd38fbf1ffd0d
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 13, 2026
…erOptions, a=testonly

Automatic update from web-platform-tests
Apply latest spec changes for createParserOptions

This aligns with:
- whatwg/html#12583
- w3c/trusted-types#606

Key changes:
- Remove default `= {}` from `SetHTMLUnsafeOptions.sanitizer` and
  `ParseHTMLUnsafeOptions.sanitizer` in IDL,
  and only populate `sanitizer`
  on the dictionary passed to `createParserOptions` when provided.
- Update `TrustedTypePolicy.createParserOptions` and
  `CreateParserOptionsCallback` to accept optional
  `SetHTMLUnsafeOptions` and variadic `any... args`, passing
  `"TrustedHTMLParserOptions"` and the
  sink name when invoked on the default policy.
- Require default policy `createParserOptions` vetting when author
  supplied parser options specify `runScripts: true` or a non-empty
  sanitizer, even
  when the input is already a `TrustedHTML`. (This is a breaking
  change! but still protected by the flag)
- Allow any `TrustedHTMLParserOptions` (even without a sanitizer) to
  satisfy Trusted Types enforcement for HTML fragment sinks, and use
  `TrustedTypesCheckForFragment` in `Document.parseHTMLUnsafe`.
- Bypass `createParserOptions` and ignore sanitization in XML
  documents,
  always requiring `TrustedHTML` for XML fragment sinks.

Bug: 491743369
Change-Id: Ia0b35e3f8720dc318aacafc117098fb3db508b30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8496967
Reviewed-by: Daniel Vogelheim <vogelheimchromium.org>
Commit-Queue: Noam Rosenthal <nrosenthalgoogle.com>
Cr-Commit-Position: refs/heads/main{#1712499}

--

wpt-commits: b5daf96de870b547d88d1a157a0be7b631db1f04
wpt-pr: 63321

UltraBlame original commit: a158e7688437ddc49df990c7863dd38fbf1ffd0d
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…izer in each call, a=testonly

Automatic update from web-platform-tests
TrustedParserOptions: return a new sanitizer in each call

This is instead of retaining a frozen copy.
See w3c/trusted-types#606

Bug: 491743369
Change-Id: Ida4d1a661edb8475cbc4a1b2ce0d0e3d38913024
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8097523
Reviewed-by: Daniel Vogelheim <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1663095}

--

wpt-commits: c1e067e2346c22c0fc98bafed6618c3d92b06af0
wpt-pr: 61339
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.

5 participants