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

Unified Diff: extensions/common/csp_validator.cc

Issue 2574763003: Remove chrome-extension-resource:// scheme (Closed)
Patch Set: Silently strip chrome-extension-resource:// from CSP directives. Created 4 years 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: extensions/common/csp_validator.cc
diff --git a/extensions/common/csp_validator.cc b/extensions/common/csp_validator.cc
index e6c789f6f8e59fce0d2afdc732efac15d82a37f6..a2e8e896b8af2d48fd9da2ef8da6d832093f881d 100644
--- a/extensions/common/csp_validator.cc
+++ b/extensions/common/csp_validator.cc
@@ -31,8 +31,7 @@ const char kObjectSrc[] = "object-src";
const char kPluginTypes[] = "plugin-types";
const char kObjectSrcDefaultDirective[] = "object-src 'self';";
-const char kScriptSrcDefaultDirective[] =
- "script-src 'self' chrome-extension-resource:;";
+const char kScriptSrcDefaultDirective[] = "script-src 'self';";
const char kSandboxDirectiveName[] = "sandbox";
const char kAllowSameOriginToken[] = "allow-same-origin";
@@ -176,13 +175,16 @@ void GetSecureDirectiveValues(const std::string& directive_name,
std::string(extensions::kExtensionScheme) +
url::kStandardSchemeSeparator,
false) ||
- IsHashSource(source_literal) ||
- base::StartsWith(source_lower, "chrome-extension-resource:",
- base::CompareCase::SENSITIVE)) {
+ IsHashSource(source_literal)) {
is_secure_csp_token = true;
} else if ((options & OPTIONS_ALLOW_UNSAFE_EVAL) &&
source_lower == "'unsafe-eval'") {
is_secure_csp_token = true;
+ } else if (base::StartsWith(source_lower, "chrome-extension-resource:",
+ base::CompareCase::SENSITIVE)) {
+ // The "chrome-extension-resource" scheme has been removed from the
+ // codebase, but it may still appear in existing CSPs. Silently ignore it.
+ continue;
}
if (is_secure_csp_token) {

Powered by Google App Engine
This is Rietveld 408576698