mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #2466 - Part 3: Implement style-src-elem and style-src-attr
This commit is contained in:
parent
ff01a35bdb
commit
721ded9b48
8 changed files with 78 additions and 12 deletions
|
|
@ -115,6 +115,7 @@ nsCSPParser::nsCSPParser(cspTokens& aTokens,
|
|||
, mFrameSrc(nullptr)
|
||||
, mWorkerSrc(nullptr)
|
||||
, mScriptSrc(nullptr)
|
||||
, mStyleSrc(nullptr)
|
||||
, mParsingFrameAncestorsDir(false)
|
||||
, mTokens(aTokens)
|
||||
, mSelfURI(aSelfURI)
|
||||
|
|
@ -1087,6 +1088,13 @@ nsCSPParser::directiveName()
|
|||
mScriptSrc = new nsCSPScriptSrcDirective(CSP_StringToCSPDirective(mCurToken));
|
||||
return mScriptSrc;
|
||||
}
|
||||
|
||||
// If we have a style-src, cache it as a fallback for style-src-elem and
|
||||
// style-src-attr.
|
||||
if (CSP_IsDirective(mCurToken, nsIContentSecurityPolicy::STYLE_SRC_DIRECTIVE)) {
|
||||
mStyleSrc = new nsCSPStyleSrcDirective(CSP_StringToCSPDirective(mCurToken));
|
||||
return mStyleSrc;
|
||||
}
|
||||
|
||||
if (CSP_IsDirective(mCurToken, nsIContentSecurityPolicy::REQUIRE_SRI_FOR)) {
|
||||
return new nsRequireSRIForDirective(CSP_StringToCSPDirective(mCurToken));
|
||||
|
|
@ -1314,6 +1322,18 @@ nsCSPParser::policy()
|
|||
mScriptSrc->setRestrictScriptAttr();
|
||||
}
|
||||
|
||||
// If style-src is specified and style-src-elem is not specified, then
|
||||
// style-src serves as a fallback.
|
||||
if (mStyleSrc && !mPolicy->hasDirective(nsIContentSecurityPolicy::STYLE_SRC_ELEM_DIRECTIVE)) {
|
||||
mStyleSrc->setRestrictStyleElem();
|
||||
}
|
||||
|
||||
// If style-src is specified and style-src-attr is not specified, then
|
||||
// style-src serves as a fallback.
|
||||
if (mStyleSrc && !mPolicy->hasDirective(nsIContentSecurityPolicy::STYLE_SRC_ATTR_DIRECTIVE)) {
|
||||
mStyleSrc->setRestrictStyleAttr();
|
||||
}
|
||||
|
||||
return mPolicy;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue