summaryrefslogtreecommitdiffstats
path: root/extensions/common
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/common')
-rw-r--r--extensions/common/csp_validator.cc12
-rw-r--r--extensions/common/features/base_feature_provider.cc8
-rw-r--r--extensions/common/manifest.cc7
-rw-r--r--extensions/common/permissions/socket_permission_data.cc5
-rw-r--r--extensions/common/permissions/socket_permission_entry.cc10
-rw-r--r--extensions/common/url_pattern.cc7
6 files changed, 24 insertions, 25 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;
diff --git a/extensions/common/features/base_feature_provider.cc b/extensions/common/features/base_feature_provider.cc
index 472e1f55..cae08d6 100644
--- a/extensions/common/features/base_feature_provider.cc
+++ b/extensions/common/features/base_feature_provider.cc
@@ -52,8 +52,8 @@ BaseFeatureProvider::BaseFeatureProvider(const base::DictionaryValue& root,
if (iter.value().GetType() == base::Value::TYPE_DICTIONARY) {
linked_ptr<SimpleFeature> feature((*factory_)());
- std::vector<std::string> split;
- base::SplitString(iter.key(), '.', &split);
+ std::vector<std::string> split = base::SplitString(
+ iter.key(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
// Push parent features on the stack, starting with the current feature.
// If one of the features has "noparent" set, stop pushing features on
@@ -171,8 +171,8 @@ Feature* BaseFeatureProvider::GetParent(Feature* feature) const {
if (feature->no_parent())
return nullptr;
- std::vector<std::string> split;
- base::SplitString(feature->name(), '.', &split);
+ std::vector<std::string> split = base::SplitString(
+ feature->name(), ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
if (split.size() < 2)
return nullptr;
split.pop_back();
diff --git a/extensions/common/manifest.cc b/extensions/common/manifest.cc
index f072488..c552de7 100644
--- a/extensions/common/manifest.cc
+++ b/extensions/common/manifest.cc
@@ -240,11 +240,10 @@ int Manifest::GetManifestVersion() const {
}
bool Manifest::CanAccessPath(const std::string& path) const {
- std::vector<std::string> components;
- base::SplitString(path, '.', &components);
std::string key;
- for (size_t i = 0; i < components.size(); ++i) {
- key += components[i];
+ for (const base::StringPiece& component : base::SplitStringPiece(
+ path, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ component.AppendToString(&key);
if (!CanAccessKey(key))
return false;
key += '.';
diff --git a/extensions/common/permissions/socket_permission_data.cc b/extensions/common/permissions/socket_permission_data.cc
index a01c20f..f22f14a 100644
--- a/extensions/common/permissions/socket_permission_data.cc
+++ b/extensions/common/permissions/socket_permission_data.cc
@@ -124,8 +124,9 @@ SocketPermissionEntry& SocketPermissionData::entry() {
bool SocketPermissionData::Parse(const std::string& permission) {
Reset();
- std::vector<std::string> tokens;
- base::SplitStringDontTrim(permission, kColon, &tokens);
+ std::vector<std::string> tokens =
+ base::SplitString(permission, std::string(1, kColon),
+ base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
if (tokens.empty())
return false;
diff --git a/extensions/common/permissions/socket_permission_entry.cc b/extensions/common/permissions/socket_permission_entry.cc
index 8b2d355..86c61de 100644
--- a/extensions/common/permissions/socket_permission_entry.cc
+++ b/extensions/common/permissions/socket_permission_entry.cc
@@ -128,8 +128,9 @@ bool SocketPermissionEntry::ParseHostPattern(
SocketPermissionRequest::OperationType type,
const std::string& pattern,
SocketPermissionEntry* entry) {
- std::vector<std::string> tokens;
- base::SplitStringDontTrim(pattern, kColon, &tokens);
+ std::vector<std::string> tokens =
+ base::SplitString(pattern, std::string(1, kColon), base::KEEP_WHITESPACE,
+ base::SPLIT_WANT_ALL);
return ParseHostPattern(type, tokens, entry);
}
@@ -168,8 +169,9 @@ bool SocketPermissionEntry::ParseHostPattern(
result.pattern_.host = base::StringToLowerASCII(result.pattern_.host);
// The first component can optionally be '*' to match all subdomains.
- std::vector<std::string> host_components;
- base::SplitString(result.pattern_.host, kDot, &host_components);
+ std::vector<std::string> host_components =
+ base::SplitString(result.pattern_.host, std::string(1, kDot),
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
DCHECK(!host_components.empty());
if (host_components[0] == kWildcard || host_components[0].empty()) {
diff --git a/extensions/common/url_pattern.cc b/extensions/common/url_pattern.cc
index 502c459..b91d438 100644
--- a/extensions/common/url_pattern.cc
+++ b/extensions/common/url_pattern.cc
@@ -237,11 +237,12 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) {
host_ = pattern.substr(host_start_pos, host_end_pos - host_start_pos);
// The first component can optionally be '*' to match all subdomains.
- std::vector<std::string> host_components;
- base::SplitString(host_, '.', &host_components);
+ std::vector<std::string> host_components = base::SplitString(
+ host_, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
// Could be empty if the host only consists of whitespace characters.
- if (host_components.empty())
+ if (host_components.empty() ||
+ (host_components.size() == 1 && host_components[0].empty()))
return PARSE_ERROR_EMPTY_HOST;
if (host_components[0] == "*") {