summaryrefslogtreecommitdiffstats
path: root/extensions/common/csp_validator.cc
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-08-07 17:28:47 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-08 00:29:27 +0000
commit26dab8f049217794bd73a230ea567021adc09672 (patch)
tree226dec9ffde922a61c6d05f0d8ee549f0a9dd02d /extensions/common/csp_validator.cc
parentdbae293445fa5a6c8ba5cea0c7290f436d1034ab (diff)
downloadchromium_src-26dab8f049217794bd73a230ea567021adc09672.zip
chromium_src-26dab8f049217794bd73a230ea567021adc09672.tar.gz
chromium_src-26dab8f049217794bd73a230ea567021adc09672.tar.bz2
Update SplitString calls to new form
Uses the new form for most (but not quite all) of the remaining users of the old form. Reland of https://codereview.chromium.org/1272823003 but with no changes to the way media parses codec lists. The previous landing attempted to simplify some handling but there are layout tests that expect the old behavior, and I'm not qualified to tell if it's OK to change. TBR=sky Review URL: https://codereview.chromium.org/1274123003 Cr-Commit-Position: refs/heads/master@{#342489}
Diffstat (limited to 'extensions/common/csp_validator.cc')
-rw-r--r--extensions/common/csp_validator.cc12
1 files changed, 4 insertions, 8 deletions
diff --git a/extensions/common/csp_validator.cc b/extensions/common/csp_validator.cc
index 1fe2217..d19b983 100644
--- a/extensions/common/csp_validator.cc
+++ b/extensions/common/csp_validator.cc
@@ -240,8 +240,8 @@ std::string SanitizeContentSecurityPolicy(
int options,
std::vector<InstallWarning>* warnings) {
// See http://www.w3.org/TR/CSP/#parse-a-csp-policy for parsing algorithm.
- std::vector<std::string> directives;
- base::SplitString(policy, ';', &directives);
+ std::vector<std::string> directives = base::SplitString(
+ policy, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
DirectiveStatus default_src_status(kDefaultSrc);
DirectiveStatus script_src_status(kScriptSrc);
@@ -307,13 +307,9 @@ std::string SanitizeContentSecurityPolicy(
bool ContentSecurityPolicyIsSandboxed(
const std::string& policy, Manifest::Type type) {
// See http://www.w3.org/TR/CSP/#parse-a-csp-policy for parsing algorithm.
- std::vector<std::string> directives;
- base::SplitString(policy, ';', &directives);
-
bool seen_sandbox = false;
-
- for (size_t i = 0; i < directives.size(); ++i) {
- std::string& input = directives[i];
+ for (const std::string& input : base::SplitString(
+ policy, ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
base::StringTokenizer tokenizer(input, " \t\r\n");
if (!tokenizer.GetNext())
continue;