From 60d87a5d19f5cf033f96b26f9597b32ad2732792 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 24 Nov 2020 00:28:55 -0800 Subject: [PATCH] Remove setInnerHTML completely The conversation [1] about the recent changes to setInnerHTML have led to the conclusion [2] that perhaps we shouldn't add a new XSS sink method at all. That would "fix" the declarative Shadow DOM problem, but would create a new sink that all security libraries would need to know about and handle. Seems like not a good trade. In the meantime, a polyfill can stand in for setInnerHTML: Element.prototype.setInnerHTML = function(content) { const fragment = (new DOMParser()).parseFromString(`
${content}
`, 'text/html', {includeShadowRoots: true}); this.replaceChildren(...fragment.body.firstChild.childNodes); }; [1] https://github.com/whatwg/dom/issues/912 [2] https://github.com/whatwg/dom/issues/912#issuecomment-732476002 Bug: 1042130 Change-Id: Ibaf15a3edf86be9a720225dea2ba2741f2882b8c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555589 Auto-Submit: Mason Freed Commit-Queue: Kouhei Ueno Reviewed-by: Kouhei Ueno Cr-Commit-Position: refs/heads/master@{#830501} --- ...ative-shadow-dom-attachment.tentative.html | 3 +- ...eclarative-shadow-dom-basic.tentative.html | 35 +++++------- ...clarative-shadow-dom-opt-in.tentative.html | 57 +++++++------------ .../declarative/setinnerhtml.tentative.html | 48 ---------------- shadow-dom/declarative/support/helpers.js | 4 ++ 5 files changed, 39 insertions(+), 108 deletions(-) delete mode 100644 shadow-dom/declarative/setinnerhtml.tentative.html create mode 100644 shadow-dom/declarative/support/helpers.js diff --git a/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html b/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html index c4a35d341c1f68..b9033f59924223 100644 --- a/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html +++ b/shadow-dom/declarative/declarative-shadow-dom-attachment.tentative.html @@ -5,6 +5,7 @@ + +