Issue #2466 - Part 3: Implement style-src-elem and style-src-attr

This commit is contained in:
Moonchild 2024-02-04 23:24:50 +01:00 committed by roytam1
commit 721ded9b48
8 changed files with 78 additions and 12 deletions

View file

@ -767,14 +767,16 @@ nsStyleUtil::CSPAllowsInlineStyle(nsIContent* aContent,
return true;
}
CSPDirective directive = nsIContentSecurityPolicy::STYLE_SRC_ATTR_DIRECTIVE;
// query the nonce
nsAutoString nonce;
if (aContent) {
directive = nsIContentSecurityPolicy::STYLE_SRC_ELEM_DIRECTIVE;
aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::nonce, nonce);
}
bool allowInlineStyle = true;
rv = csp->GetAllowsInline(nsIContentSecurityPolicy::STYLE_SRC_DIRECTIVE,
rv = csp->GetAllowsInline(directive,
nonce,
false, // aParserCreated only applies to scripts
aStyleText, aLineNumber, aColumnNumber,