From 26dab8f049217794bd73a230ea567021adc09672 Mon Sep 17 00:00:00 2001 From: brettw Date: Fri, 7 Aug 2015 17:28:47 -0700 Subject: 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} --- extensions/common/csp_validator.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'extensions/common/csp_validator.cc') 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* warnings) { // See http://www.w3.org/TR/CSP/#parse-a-csp-policy for parsing algorithm. - std::vector directives; - base::SplitString(policy, ';', &directives); + std::vector 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 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; -- cgit v1.1