summaryrefslogtreecommitdiffstats
path: root/extensions/common/csp_validator.cc
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-08-06 17:11:28 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-07 00:12:13 +0000
commit0aa7c64253cca8b636d52d1d01d94f96ab9c13fa (patch)
tree29b825a84dffc4d7310c69b22da0cfd7b1228277 /extensions/common/csp_validator.cc
parent924597ba8b5def174aebdc96368545f51df1bee2 (diff)
downloadchromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.zip
chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.tar.gz
chromium_src-0aa7c64253cca8b636d52d1d01d94f96ab9c13fa.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. Changes media mime util codec list parsing to expect no result from the string "," rather than two empty strings. The old SplitString call had a special case where if the input was empty, it would return empty, but if it had one split character, it would return two empty strings as results. The new one lets you choose but the options are either (1) empty string -> one empty string and "," -> two empty strings, or (2) map both to no results for when you don't want empty results. I'm pretty sure media codec parsing actually wants the latter behavior, so I updated the call to discard empty results and MimeUtilTest.ParseCodecString is updated. Review URL: https://codereview.chromium.org/1272823003 Cr-Commit-Position: refs/heads/master@{#342238}
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;