mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 23:38:38 +09:00
Issue #2402 - Fix SecurityPolicyViolationEvent.violatedDirective. https://bugzilla.mozilla.org/show_bug.cgi?id=1418243
This commit is contained in:
parent
ec29404083
commit
1e0851158e
3 changed files with 80 additions and 12 deletions
|
|
@ -1264,6 +1264,12 @@ bool nsCSPDirective::equals(CSPDirective aDirective) const
|
|||
return (mDirective == aDirective);
|
||||
}
|
||||
|
||||
void
|
||||
nsCSPDirective::getDirName(nsAString& outStr) const
|
||||
{
|
||||
outStr.AppendASCII(CSP_CSPDirectiveToString(mDirective));
|
||||
}
|
||||
|
||||
/* =============== nsCSPChildSrcDirective ============= */
|
||||
|
||||
nsCSPChildSrcDirective::nsCSPChildSrcDirective(CSPDirective aDirective)
|
||||
|
|
@ -1349,6 +1355,13 @@ nsBlockAllMixedContentDirective::toString(nsAString& outStr) const
|
|||
nsIContentSecurityPolicy::BLOCK_ALL_MIXED_CONTENT));
|
||||
}
|
||||
|
||||
void
|
||||
nsBlockAllMixedContentDirective::getDirName(nsAString& outStr) const
|
||||
{
|
||||
outStr.AppendASCII(CSP_CSPDirectiveToString(
|
||||
nsIContentSecurityPolicy::BLOCK_ALL_MIXED_CONTENT));
|
||||
}
|
||||
|
||||
/* =============== nsUpgradeInsecureDirective ============= */
|
||||
|
||||
nsUpgradeInsecureDirective::nsUpgradeInsecureDirective(CSPDirective aDirective)
|
||||
|
|
@ -1367,6 +1380,13 @@ nsUpgradeInsecureDirective::toString(nsAString& outStr) const
|
|||
nsIContentSecurityPolicy::UPGRADE_IF_INSECURE_DIRECTIVE));
|
||||
}
|
||||
|
||||
void
|
||||
nsUpgradeInsecureDirective::getDirName(nsAString& outStr) const
|
||||
{
|
||||
outStr.AppendASCII(CSP_CSPDirectiveToString(
|
||||
nsIContentSecurityPolicy::UPGRADE_IF_INSECURE_DIRECTIVE));
|
||||
}
|
||||
|
||||
/* ===== nsRequireSRIForDirective ========================= */
|
||||
|
||||
nsRequireSRIForDirective::nsRequireSRIForDirective(CSPDirective aDirective)
|
||||
|
|
@ -1418,6 +1438,13 @@ nsRequireSRIForDirective::allows(enum CSPKeyword aKeyword, const nsAString& aHas
|
|||
return (aKeyword != CSP_REQUIRE_SRI_FOR);
|
||||
}
|
||||
|
||||
void
|
||||
nsRequireSRIForDirective::getDirName(nsAString& outStr) const
|
||||
{
|
||||
outStr.AppendASCII(CSP_CSPDirectiveToString(
|
||||
nsIContentSecurityPolicy::REQUIRE_SRI_FOR));
|
||||
}
|
||||
|
||||
/* ===== nsCSPPolicy ========================= */
|
||||
|
||||
nsCSPPolicy::nsCSPPolicy()
|
||||
|
|
@ -1471,7 +1498,7 @@ nsCSPPolicy::permits(CSPDirective aDir,
|
|||
if (mDirectives[i]->equals(aDir)) {
|
||||
if (!mDirectives[i]->permits(aUri, aNonce, aWasRedirected, mReportOnly,
|
||||
mUpgradeInsecDir, aParserCreated)) {
|
||||
mDirectives[i]->toString(outViolatedDirective);
|
||||
mDirectives[i]->getDirName(outViolatedDirective);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -1486,7 +1513,7 @@ nsCSPPolicy::permits(CSPDirective aDir,
|
|||
if (!aSpecific && defaultDir) {
|
||||
if (!defaultDir->permits(aUri, aNonce, aWasRedirected, mReportOnly,
|
||||
mUpgradeInsecDir, aParserCreated)) {
|
||||
defaultDir->toString(outViolatedDirective);
|
||||
defaultDir->getDirName(outViolatedDirective);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -1612,7 +1639,7 @@ nsCSPPolicy::getDirectiveStringForContentType(nsContentPolicyType aContentType,
|
|||
nsCSPDirective* defaultDir = nullptr;
|
||||
for (uint32_t i = 0; i < mDirectives.Length(); i++) {
|
||||
if (mDirectives[i]->restrictsContentType(aContentType)) {
|
||||
mDirectives[i]->toString(outDirective);
|
||||
mDirectives[i]->getDirName(outDirective);
|
||||
return;
|
||||
}
|
||||
if (mDirectives[i]->isDefaultDirective()) {
|
||||
|
|
@ -1622,7 +1649,7 @@ nsCSPPolicy::getDirectiveStringForContentType(nsContentPolicyType aContentType,
|
|||
// if we haven't found a matching directive yet,
|
||||
// the contentType must be restricted by the default directive
|
||||
if (defaultDir) {
|
||||
defaultDir->toString(outDirective);
|
||||
defaultDir->getDirName(outDirective);
|
||||
return;
|
||||
}
|
||||
NS_ASSERTION(false, "Can not query directive string for contentType!");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue