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

Unified Diff: third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp

Issue 2896833002: Added validation of the policy specified in the 'csp' attribute (Closed)
Patch Set: Code Review suggestions 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/html/HTMLIFrameElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp b/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp
index a76ad50915efe1223077894e8f4f05070bf85fd5..2bbce298735d71291954d3af23d3999875428fc7 100644
--- a/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp
@@ -27,6 +27,7 @@
#include "core/CSSPropertyNames.h"
#include "core/HTMLNames.h"
#include "core/frame/UseCounter.h"
+#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/HTMLDocument.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/layout/LayoutIFrame.h"
@@ -167,12 +168,11 @@ void HTMLIFrameElement::ParseAttribute(
}
} else if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() &&
name == cspAttr) {
- // TODO(amalika): add more robust validation of the value
- if (!value.GetString().ContainsOnlyASCII()) {
+ if (!ContentSecurityPolicy::IsValidCSPAttr(value.GetString())) {
csp_ = g_null_atom;
GetDocument().AddConsoleMessage(ConsoleMessage::Create(
kOtherMessageSource, kErrorMessageLevel,
- "'csp' attribute contains non-ASCII characters: " + value));
+ "'csp' attribute is not a valid policy: " + value));
return;
}
AtomicString old_csp = csp_;

Powered by Google App Engine
This is Rietveld 408576698