summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/common/url_pattern.cc5
-rw-r--r--extensions/common/url_pattern_unittest.cc1
2 files changed, 6 insertions, 0 deletions
diff --git a/extensions/common/url_pattern.cc b/extensions/common/url_pattern.cc
index ee7d164..b667981 100644
--- a/extensions/common/url_pattern.cc
+++ b/extensions/common/url_pattern.cc
@@ -228,6 +228,11 @@ URLPattern::ParseResult URLPattern::Parse(const std::string& pattern) {
// The first component can optionally be '*' to match all subdomains.
std::vector<std::string> host_components;
base::SplitString(host_, '.', &host_components);
+
+ // Could be empty if the host only consists of whitespace characters.
+ if (host_components.empty())
+ return PARSE_ERROR_EMPTY_HOST;
+
if (host_components[0] == "*") {
match_subdomains_ = true;
host_components.erase(host_components.begin(),
diff --git a/extensions/common/url_pattern_unittest.cc b/extensions/common/url_pattern_unittest.cc
index 3e0c816..8f353cc 100644
--- a/extensions/common/url_pattern_unittest.cc
+++ b/extensions/common/url_pattern_unittest.cc
@@ -31,6 +31,7 @@ TEST(ExtensionURLPatternTest, ParseInvalid) {
{ "about://", URLPattern::PARSE_ERROR_WRONG_SCHEME_SEPARATOR },
{ "http://", URLPattern::PARSE_ERROR_EMPTY_HOST },
{ "http:///", URLPattern::PARSE_ERROR_EMPTY_HOST },
+ { "http:// /", URLPattern::PARSE_ERROR_EMPTY_HOST },
{ "http://*foo/bar", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD },
{ "http://foo.*.bar/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD },
{ "http://fo.*.ba:123/baz", URLPattern::PARSE_ERROR_INVALID_HOST_WILDCARD },