Skip to content

Commit 1f20089

Browse files
fred-wangmoz-wptsync-bot
authored andcommitted
Ensure element's namespace is HTML, SVG or MathML before TT check for event handler attribute.
See w3c/trusted-types#578 Differential Revision: https://phabricator.services.mozilla.com/D239724 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1950582 gecko-commit: e51862a3ae02677d09e17aa99baa8ec6ed18678a gecko-reviewers: smaug
1 parent e435fc2 commit 1f20089

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

trusted-types/TrustedTypePolicyFactory-getAttributeType-event-handler-content-attributes.tentative.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
promise_test(async () => {
1515
NSURI_ARRAY.forEach(attrNs => {
1616
assert_equals(trustedTypes.getAttributeType(
17-
"dummy", attr.name, "dummyNs", attrNs),
17+
"dummy", attr.name, NSURI_HTML, attrNs),
1818
attrNs === NSURI_EMPTY ? "TrustedScript" : null,
1919
`for attrNs='${attrNs}'`);
2020
});

trusted-types/support/attributes.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@ const trustedTypeDataForAttribute = [
5151
type: "TrustedScript",
5252
sink: "Element onmousedown"
5353
},
54-
{
55-
element: _ => document.createElementNS(NSURI_FOO, "foo"),
56-
attrNS: null,
57-
attrName: "onmouseup",
58-
type: "TrustedScript",
59-
sink: "Element onmouseup"
60-
},
6154
{
6255
element: _ => document.createElement("iframe"),
6356
attrNS: null,
@@ -87,6 +80,13 @@ const trustedTypeDataForAttribute = [
8780
sink: "SVGScriptElement href",
8881
},
8982
// Below are some cases that are not trusted type sinks.
83+
// event handler attribute name with element in non-HTML/SVG/MathML namespace.
84+
{
85+
element: _ => document.createElementNS(NSURI_FOO, "foo"),
86+
attrNS: null,
87+
attrName: "onmouseup",
88+
type: null,
89+
},
9090
{
9191
// event handler attribute name with non-null namespace.
9292
element: _ => document.createElement("div"),

0 commit comments

Comments
 (0)