Bug 1959949 - Don't reparse empty style attributes. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D245400
This commit is contained in:
Tom Schuster
2025-04-14 11:56:56 +00:00
parent 363f64a736
commit 2df53d3d7e

View File

@@ -138,7 +138,10 @@ nsresult nsStyledElement::ReparseStyleAttribute(bool aForceInDataDoc) {
nsAttrValue attrValue;
nsAutoString stringValue;
oldVal->ToString(stringValue);
ParseStyleAttribute(stringValue, nullptr, attrValue, aForceInDataDoc);
if (!stringValue.IsEmpty()) {
// Prevent CSP errors from re-parsing a style that was already blocked.
ParseStyleAttribute(stringValue, nullptr, attrValue, aForceInDataDoc);
}
// Don't bother going through SetInlineStyleDeclaration; we don't
// want to fire off mutation events or document notifications anyway
bool oldValueSet;
@@ -168,8 +171,9 @@ void nsStyledElement::ParseStyleAttribute(const nsAString& aValue,
if (!isNativeAnon &&
!nsStyleUtil::CSPAllowsInlineStyle(this, doc, aMaybeScriptedPrincipal, 0,
1, aValue, nullptr))
1, aValue, nullptr)) {
return;
}
if (aForceInDataDoc || !doc->IsLoadedAsData() || GetExistingStyle() ||
doc->IsStaticDocument()) {