summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'extensions')
-rw-r--r--extensions/common/matcher/url_matcher_factory.cc3
-rw-r--r--extensions/common/matcher/url_matcher_factory_unittest.cc10
2 files changed, 12 insertions, 1 deletions
diff --git a/extensions/common/matcher/url_matcher_factory.cc b/extensions/common/matcher/url_matcher_factory.cc
index 80e27f6..d35d032 100644
--- a/extensions/common/matcher/url_matcher_factory.cc
+++ b/extensions/common/matcher/url_matcher_factory.cc
@@ -203,7 +203,8 @@ URLMatcherCondition URLMatcherFactory::CreateURLMatcherCondition(
}
// Test regular expressions for validity.
- if (condition_attribute_name == keys::kURLMatchesKey) {
+ if (condition_attribute_name == keys::kURLMatchesKey ||
+ condition_attribute_name == keys::kOriginAndPathMatchesKey) {
re2::RE2 regex(str_value);
if (!regex.ok()) {
*error = ErrorUtils::FormatErrorMessage(kUnparseableRegexString,
diff --git a/extensions/common/matcher/url_matcher_factory_unittest.cc b/extensions/common/matcher/url_matcher_factory_unittest.cc
index 7738c4d..1f56916 100644
--- a/extensions/common/matcher/url_matcher_factory_unittest.cc
+++ b/extensions/common/matcher/url_matcher_factory_unittest.cc
@@ -34,6 +34,10 @@ TEST(URLMatcherFactoryTest, CreateFromURLFilterDictionary) {
DictionaryValue invalid_condition3;
invalid_condition3.SetString(keys::kURLMatchesKey, "*");
+ // Invalid regex value: {"originAndPathMatches": "*"}
+ DictionaryValue invalid_condition4;
+ invalid_condition4.SetString(keys::kOriginAndPathMatchesKey, "*");
+
// Valid values:
// {
// "port_range": [80, [1000, 1010]],
@@ -80,6 +84,12 @@ TEST(URLMatcherFactoryTest, CreateFromURLFilterDictionary) {
EXPECT_FALSE(error.empty());
EXPECT_FALSE(result.get());
+ error.clear();
+ result = URLMatcherFactory::CreateFromURLFilterDictionary(
+ matcher.condition_factory(), &invalid_condition4, 4, &error);
+ EXPECT_FALSE(error.empty());
+ EXPECT_FALSE(result.get());
+
// Test success.
error.clear();
result = URLMatcherFactory::CreateFromURLFilterDictionary(