diff options
author | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 13:14:27 +0000 |
---|---|---|
committer | vabr@chromium.org <vabr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 13:14:27 +0000 |
commit | 1a3a021deb4d168468601060fb6a833a5ee72029 (patch) | |
tree | 922df26731f5f1eda6f9e3fc0270ac9721f002c1 /extensions | |
parent | ae80691462e105b7b9be70950d607802c076a0bc (diff) | |
download | chromium_src-1a3a021deb4d168468601060fb6a833a5ee72029.zip chromium_src-1a3a021deb4d168468601060fb6a833a5ee72029.tar.gz chromium_src-1a3a021deb4d168468601060fb6a833a5ee72029.tar.bz2 |
Add a RE2 syntax check for kOriginAndPathMatchesKey
It looks like this was missed in
https://chromiumcodereview.appspot.com/13699007/.
There are two "url" filter attributes for Declarative Web Request which use regular expressions: kURLMatchesKey and kOriginAndPathMatchesKey. The former had a RE2 validity check in place, whereas the other did not. Fixing this.
BUG=228852
R=battre@chromium.org
Review URL: https://codereview.chromium.org/14031037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/common/matcher/url_matcher_factory.cc | 3 | ||||
-rw-r--r-- | extensions/common/matcher/url_matcher_factory_unittest.cc | 10 |
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( |