Remove custom element state when is attribute is blocked#396
Conversation
|
Looks good editorially, but I wonder whether this would execute the custom element constructor during parsing? As I understand this, this would create the custom element, and then later remove it again. If so, I'd expect this to execute the custom element's constructor, and thus bypass sanitization in a sense. |
No it doesn't AFAIK. The custom constructor (if not removed) is only invoked when inserting. IIRC because the custom elements registry is null for those documents we use for parsing? You can actually try this out with |
|
Rebased. Should be ready for review, but can't land before whatwg/html#12533 of course. |
|
@otherdaniel I would appreciate your review on this! |
|
Maybe wait with this until after the upstream? |
…ute is blocked. r=emilio Implements WICG/sanitizer-api#396 Differential Revision: https://phabricator.services.mozilla.com/D301304
To be honest, I'm still a little confused here.
So... the way I read the specs, I'd still expect your example of As an additional point.. if the HTML fragment parsing algorithm doesn't run the custom element constructor anyhow, then why do we even bother with this whole thing? My understanding is that the sanitizer algorithm sits between the parsing and insertion in the document. If the whole logic only runs when inserting and thus after sanitization, wouldn't this whole point be moot? As said above... I find the whole thing confusing, and am not very confident in my analysis above. Our implementation seems to slightly deviate from what I find in the specs, in that a custom element registry is expressedly passed in to the parser, and when |scripting mode| is |
Implements WICG/sanitizer-api#396 Differential Revision: https://phabricator.services.mozilla.com/D301304 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2040656 gecko-commit: d8f0a20748554395560938baabeaa80986c758cc gecko-commit-git: beca389380ebb98e7631ffc4c3f06e55d765b009 gecko-reviewers: emilio
…ute is blocked. r=emilio Implements WICG/sanitizer-api#396 Differential Revision: https://phabricator.services.mozilla.com/D301304 UltraBlame original commit: d8f0a20748554395560938baabeaa80986c758cc
…ute is blocked. r=emilio Implements WICG/sanitizer-api#396 Differential Revision: https://phabricator.services.mozilla.com/D301304 UltraBlame original commit: d8f0a20748554395560938baabeaa80986c758cc
…ute is blocked. r=emilio Implements WICG/sanitizer-api#396 Differential Revision: https://phabricator.services.mozilla.com/D301304 UltraBlame original commit: d8f0a20748554395560938baabeaa80986c758cc
|
I don't really feel confident with the behavior here either, but I do want to try and understand this:
I am not sure what you mean here. Do you think the whole idea of trying to prevent the usage of From my point of view we definitely don't want to execute custom element callbacks with a default config, in fact I have landed patches in Firefox which already implement this proposal. But I do think the specification, Chrome and Firefox are probably all different in this area. |
|
The problem is not that it executes while parsing, but that the callback fires when connected to the main document. And a null registry is patched at that point during connection. This is very similar to script elements which we also disallow. |
No. I meant this as a "proof by contradiction" type argument: Before sanitizing, we run the HTML fragment parsing algorithm + copying nodes into a fragment. If we were sure those steps, any pre-sanitize-core steps in fact, would never call or enque calling constructors, then we could just sanitize as normal and this whole issue wouldn't exist. Not sure that was a particularly compelling argument, so if this is too confusing please just ignore it... :-) I do think everyone agrees on the desired behaviour here. I think the disagreement is merely about the mechanism, or maybe the spec-ification of the mechanism. If the proposed wording works, I'm happy! I recently landed a fix on our side, which works by making sure
(I expect Edge to pass 100% too, as soon as they pick up the patch. They're on a slightly different release cycle than us.) |
This depends on changes in #385 that haven't happened yet.
I am not really certain if there isn't some other data structure that we need to patch for this. Presumably this would be easier to specify when we do streaming parsing.
Fixes whatwg/html#12533.
Preview | Diff