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

Ability to configure whether script elements should execute for setHTMLUnsafe() #10090

Open
zcorpan opened this issue Jan 25, 2024 · 0 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: parser topic: script

Comments

@zcorpan
Copy link
Member

zcorpan commented Jan 25, 2024

What is the issue with the HTML Standard?

Currently innerHTML and insertContextualFragment() will not execute script elements because:

https://html.spec.whatwg.org/#script-processing-model:already-started-4 sets "already started" to true when the element is inserted into the temporary document during fragment parsing, and step 17 returns because scripting is disabled for that document. Then when the elements are inserted into the right place, "already started" is still true and https://html.spec.whatwg.org/#script-processing-model:already-started-3 returns.

Range.createContextualFragment() unsets the "already started" flag and therefore runs scripts: https://w3c.github.io/DOM-Parsing/#dom-range-createcontextualfragment (step 4).

In a previous meeting for Sanitizer API, we discussed this for setHTMLUnsafe() and the group's general agreement was that we should align with innerHTML by default but in the future we can allow a config to make script elements execute.

(This was originally filed at WICG/sanitizer-api#195 )

cc @whatwg/html-parser @mozfreddyb

@zcorpan zcorpan added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: parser topic: script labels Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: parser topic: script
Development

No branches or pull requests

2 participants
@zcorpan and others