Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated event handler section #495

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,8 @@ To <dfn abstract-op export>get Trusted Types-compliant attribute value</dfn> on

If the algorithm threw an error, rethrow the error.

Issue: This algorithm should account for event handler attributes. See https://github.com/w3c/trusted-types/issues/474

# Integrations # {#integrations}

<pre class="idl">
Expand Down Expand Up @@ -1242,37 +1244,6 @@ change step 8.4.3 as follows:

1. Perform <del>HostEnsureCanCompileStrings</del><ins>EnsureCSPDoesNotBlockStringCompilation</ins>(<var>realm</var>, « », <var>handler</var>,<del> false</del><ins>, <var>handler</var>, ~timer~, « », <var>handler</var></ins>). If this throws an exception, catch it, report the exception, and abort these steps.

### Enforcement in event handler content attributes ### {#enforcement-in-event-handler-content-attributes}

This document modifies the
[=attribute change steps=] for an [[HTML5#event-handler-content-attributes|event handler content attribute]].

At the beginning of step 5, insert the following steps:

1. Let |value| be the result of executing the
[$Get Trusted Type compliant string$] algorithm, with the following arguments:
* |value| as |input|,
* {{TrustedScript}} as |expectedType|,
* `'script'` as |sinkGroup|
* |sink| being the result of [=concatenating=] the list &laquo; <var ignore>element</var>'s [=Element/local name=], |localName| &raquo; with `"."` as a |separator|.

Note: For example, `document.createElement('div').onclick = value` will result in |sink| being `'div.onclick'`.

* <var ignore>eventTarget</var>'s [=relevant global object=] as |global|,

1. If the algorithm throws an error, abort these steps.

Note: This also applies to events in [[SVG2#EventAttributes]].

<div class="example" id="event-handlers-example">
<pre highlight=js>
// Content-Security-Policy: require-trusted-types-for 'script'

const img = document.createElement('img');
img.setAttribute('onerror', 'alert(1)'); // TypeError
</pre>
</div>

### HostEnsureCanCompileStrings ### {#host-ensure-can-compile-strings}

JavaScript contains an <span>implementation-defined</span> <a href="https://tc39.es/ecma262/#sec-hostensurecancompilestrings">HostEnsureCanCompileStrings</a>(<var>realm</var>, <ins><var>parameterStrings</var>,
Expand Down
Loading