Skip to content
Snippets Groups Projects
Commit f7d6eb2e authored by CanadaHonk's avatar CanadaHonk
Browse files

Bug 1834110 - Do not run script elements with whitespace type attribute values r=peterv

Fixed running script elements with a type attribute value with whitespace
(like " ").

Fixed by comparing value emptiness before and after trim, if not empty
before and empty after, undo the trim.

2 WPT subtests now newly pass.

WPT tests: https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/script-type-and-language-js.html

Differential Revision: https://phabricator.services.mozilla.com/D178573
parent c944276c
No related merge requests found
......@@ -151,8 +151,17 @@ bool HTMLScriptElement::GetScriptType(nsAString& aType) {
// ASCII whitespace https://infra.spec.whatwg.org/#ascii-whitespace:
// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, or U+0020 SPACE.
static const char kASCIIWhitespace[] = "\t\n\f\r ";
const bool wasEmptyBeforeTrim = type.IsEmpty();
type.Trim(kASCIIWhitespace);
// If the value before trim was not empty and the value is now empty, do not
// trim as we want to retain pure whitespace (by restoring original value)
// because we need to treat "" and " " (etc) differently.
if (!wasEmptyBeforeTrim && type.IsEmpty()) {
return GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
}
aType.Assign(type);
return true;
}
......
[script-type-and-language-js-xhtml.xhtml]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[Script shouldn't run with type=" "]
expected: FAIL
[script-type-and-language-js.html]
expected:
if (os == "android") and fission: [OK, TIMEOUT]
[Script shouldn't run with type=" "]
expected: FAIL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment