summaryrefslogtreecommitdiffstats
path: root/dom/security/nsCSPContext.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-09-06 10:31:35 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-09-06 10:31:35 +0200
commit0f7f961e8894c8408b7fa21bbeba7ac503d372eb (patch)
tree033c37b3e8ca856d8b35d2408afa5269f0237078 /dom/security/nsCSPContext.cpp
parentdba27e6f639954060b9353c6d8f594eab0e06a99 (diff)
parent6db06749e2037029adc96660aafa5339ed609e60 (diff)
downloadUXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar
UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar.gz
UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar.lz
UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar.xz
UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.zip
Merge branch 'master' into Basilisk-releasev2019.09.12
Diffstat (limited to 'dom/security/nsCSPContext.cpp')
-rw-r--r--dom/security/nsCSPContext.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/dom/security/nsCSPContext.cpp b/dom/security/nsCSPContext.cpp
index 65be02809..56a119e1a 100644
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -513,8 +513,19 @@ nsCSPContext::GetAllowsInline(nsContentPolicyType aContentType,
for (uint32_t i = 0; i < mPolicies.Length(); i++) {
bool allowed =
mPolicies[i]->allows(aContentType, CSP_UNSAFE_INLINE, EmptyString(), aParserCreated) ||
- mPolicies[i]->allows(aContentType, CSP_NONCE, aNonce, aParserCreated) ||
- mPolicies[i]->allows(aContentType, CSP_HASH, aContent, aParserCreated);
+ mPolicies[i]->allows(aContentType, CSP_NONCE, aNonce, aParserCreated);
+
+ // If the inlined script or style is allowed by either unsafe-inline or the
+ // nonce, go ahead and shortcut this loop.
+ if (allowed) {
+ continue;
+ }
+
+ // Check if the csp-hash matches against the hash of the script.
+ // If we don't have any content to check, block the script.
+ if (!aContent.IsEmpty()) {
+ allowed = mPolicies[i]->allows(aContentType, CSP_HASH, aContent, aParserCreated);
+ }
if (!allowed) {
// policy is violoated: deny the load unless policy is report only and