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

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

Issue 2896833002: Added validation of the policy specified in the 'csp' attribute (Closed)
Patch Set: Moved everything to ContentSecurityPolicy Created 3 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/ContentSecurityPolicy.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
index 529501b3539cd032b119e70c16308485b2786b98..8effd33654dfda047d7c9ddcd0722d8d47b0d73f 100644
--- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -1709,4 +1709,18 @@ bool ContentSecurityPolicy::ShouldBypassContentSecurityPolicy(
}
}
+// static
+bool ContentSecurityPolicy::IsValidCSPAttr(const String& attr) {
+ if (attr.IsEmpty() || attr.find(',') != kNotFound)
+ return false;
Mike West 2017/05/29 13:49:31 Hrm. I think I'd prefer that you do both of these
andypaicu 2017/05/30 08:51:22 Done
+ ContentSecurityPolicy* policy = ContentSecurityPolicy::Create();
+ policy->AddPolicyFromHeaderValue(attr,
+ kContentSecurityPolicyHeaderTypeEnforce,
+ kContentSecurityPolicyHeaderSourceHTTP);
+ if (policy->console_messages_.IsEmpty()) {
+ return true;
+ }
+ return false;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698