Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp

Issue 2006653005: Fix bug where a second CSP without script-src would cause failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Address estark's comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp b/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
index 21d5e070a42b0dfaa8f2da0329e48759df2d5c1d..0ba9245938d6c0f7eacd572460732ce64cc3f8d3 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp
@@ -417,14 +417,20 @@ bool CSPDirectiveList::allowAncestors(LocalFrame* frame, const KURL& url, Conten
return reportingStatus == ContentSecurityPolicy::SendReport ? checkAncestorsAndReportViolation(m_frameAncestors.get(), frame, url) : checkAncestors(m_frameAncestors.get(), frame);
}
-bool CSPDirectiveList::allowScriptNonce(const String& nonce) const
+CSPDirectiveList::NoncePolicyDisposition CSPDirectiveList::allowScriptNonce(const String& nonce) const
{
- return checkNonce(operativeDirective(m_scriptSrc.get()), nonce);
+ SourceListDirective* directive = operativeDirective(m_scriptSrc.get());
+ if (!directive)
+ return NoncePolicyDisposition::NoDirective;
+ return checkNonce(directive, nonce) ? NoncePolicyDisposition::Allowed : NoncePolicyDisposition::Denied;
}
-bool CSPDirectiveList::allowStyleNonce(const String& nonce) const
+CSPDirectiveList::NoncePolicyDisposition CSPDirectiveList::allowStyleNonce(const String& nonce) const
{
- return checkNonce(operativeDirective(m_styleSrc.get()), nonce);
+ SourceListDirective* directive = operativeDirective(m_styleSrc.get());
+ if (!directive)
+ return NoncePolicyDisposition::NoDirective;
+ return checkNonce(directive, nonce) ? NoncePolicyDisposition::Allowed : NoncePolicyDisposition::Denied;
}
bool CSPDirectiveList::allowScriptHash(const CSPHashValue& hashValue, ContentSecurityPolicy::InlineType type) const

Powered by Google App Engine
This is Rietveld 408576698