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

Clarify that <details open> fires the toggle event even if the open attribute is set from the parser #4500

Closed
emilio opened this issue Apr 3, 2019 · 12 comments · Fixed by #4574
Assignees
Labels
clarification Standard could be clearer

Comments

@emilio
Copy link
Contributor

emilio commented Apr 3, 2019

https://html.spec.whatwg.org/#the-details-element says:

Whenever the open attribute is added to or removed from a details element, the user agent must queue a task that runs the following steps, which are known as the details notification task steps, for this details element:
[...]

That doesn't say what happens when the parser sets the attribute, so e.g., you load data:text/html,<details open ontoggle="alert(1)">.

Looks like all implementations are interoperable in this case, but it's not so obvious from the spec text, so should probably be clarified. I can write a test.

@domenic
Copy link
Member

domenic commented Apr 3, 2019

Good catch. Can you think of anything clearer than just adding "(including by the parser)" to that sentence? It feels a bit unsatisfying, but I don't have any better ideas.

@emilio
Copy link
Contributor Author

emilio commented Apr 3, 2019

That sounds ok to me. web-platform-tests/wpt#16244 is the test for this.

@annevk annevk added the clarification Standard could be clearer label Apr 5, 2019
@annevk
Copy link
Member

annevk commented Apr 8, 2019

It seems bad to me that this would dispatch in an XMLHttpRequest document or a HTML module. That could lead to some very surprising behavior and potentially attacks.

@domenic
Copy link
Member

domenic commented Apr 26, 2019

I've posted a PR for this at #4574 to align with all existing browsers. Are implementers interested in all changing? I'm skeptical of the value, but I want to be sensitive to @annevk's concerns, so pinging @cdumez / @rniwa @emilio @tkent-google.

@emilio
Copy link
Contributor Author

emilio commented Apr 27, 2019

We'd probably need data to prove that people are not relying on that behavior...

It's yet another XSS vector, but not sure if that's enough justification to change it (it's not more of an XSS vector than <img onerror> and such).

@emilio
Copy link
Contributor Author

emilio commented Apr 27, 2019

Oh re-reading my own comment, I guess <img onerror> doesn't trigger the load if the <img> is not connected, I guess that's what @annevk was arguing?

Is there another precedent for something like this?

@annevk
Copy link
Member

annevk commented Apr 30, 2019

There's no precedent, this is pretty bad. Having said that, I cannot get

client = new XMLHttpRequest()
client.open("GET", 'data:text/xml,<html xmlns="http://www.w3.org/1999/xhtml"><details open="" ontoggle="alert(1)"/></html>', false);
client.send();
console.log(client.responseXML);

to run script in browsers, so this will need more tests and more complicated behavior if we wanted to go down this route, right?

@domenic
Copy link
Member

domenic commented Apr 30, 2019

Scripting is disabled in XML responseDocs. The event fires, but you have to add the handler from outside. See web-platform-tests/wpt#16244 for an example.

@tkent-google
Copy link
Contributor

I filed crbug.com/960252 for adding a new counter to Chrome.

@tkent-google
Copy link
Contributor

I filed crbug.com/960252 for adding a new counter to Chrome.

Result: less than 0.0004% https://chromestatus.com/metrics/feature/timeline/popularity/2978

I think we can change this behavior.

@annevk
Copy link
Member

annevk commented Nov 7, 2019

I'd propose we add "is browsing-context connected" to the conditions for queuing the task to fire the event.

@domenic
Copy link
Member

domenic commented Sep 15, 2023

At TPAC 2023 we discussed this and are generally OK with firing events from the parser. I'll work on driving #4574 and web-platform-tests/wpt#16244 to completion.

@domenic domenic self-assigned this Sep 15, 2023
domenic added a commit that referenced this issue Nov 1, 2023
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 14, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244
vinnydiehl pushed a commit to vinnydiehl/mozilla-unified that referenced this issue Nov 15, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 16, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244

UltraBlame original commit: 93d1a7cfc9b50da825cb82bd72fabbd30218c41f
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 16, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244

UltraBlame original commit: 93d1a7cfc9b50da825cb82bd72fabbd30218c41f
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 16, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244

UltraBlame original commit: 93d1a7cfc9b50da825cb82bd72fabbd30218c41f
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Nov 20, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244
jamienicol pushed a commit to jamienicol/gecko that referenced this issue Nov 20, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Nov 21, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244

UltraBlame original commit: 582cc4d01280d499d3511ee56ad2d302c64758af
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Nov 21, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244

UltraBlame original commit: 582cc4d01280d499d3511ee56ad2d302c64758af
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Nov 21, 2023
… event even from the parser., a=testonly

Automatic update from web-platform-tests
HTML: Test that <details open> fires the event even from the parser.

whatwg/html#4500

--

wpt-commits: 06854ec7854c9061b84a8d675ff6fb8f0dcd08fc
wpt-pr: 16244

UltraBlame original commit: 582cc4d01280d499d3511ee56ad2d302c64758af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

Successfully merging a pull request may close this issue.

4 participants