diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 08:18:46 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 08:18:46 +0000 |
commit | 4493574d71becba0ad1cbb74ce600466cc4f33e0 (patch) | |
tree | f50e1a49a49043de9e134087cb98f3b337fdf3b1 /chrome/common | |
parent | a15cbd47814d62163e2d66e64e7cb9e144fa5ca1 (diff) | |
download | chromium_src-4493574d71becba0ad1cbb74ce600466cc4f33e0.zip chromium_src-4493574d71becba0ad1cbb74ce600466cc4f33e0.tar.gz chromium_src-4493574d71becba0ad1cbb74ce600466cc4f33e0.tar.bz2 |
Make the glob matcher support UTF8 strings.
This generalizes the existing pattern matching code to support UTF8 strings.
BUG=53158
TEST=string_util_unittests.cc
Review URL: http://codereview.chromium.org/3295018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59071 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/extension_manifests_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unittest.cc | 48 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unpacker_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 4 | ||||
-rw-r--r-- | chrome/common/extensions/url_pattern.h | 6 | ||||
-rw-r--r-- | chrome/common/extensions/user_script.cc | 4 |
6 files changed, 35 insertions, 35 deletions
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc index 42c994c..2b1183f 100644 --- a/chrome/common/extensions/extension_manifests_unittest.cc +++ b/chrome/common/extensions/extension_manifests_unittest.cc @@ -97,7 +97,7 @@ class ExtensionManifestTest : public testing::Test { EXPECT_FALSE(extension) << "Expected failure loading extension '" << name << "', but didn't get one."; - EXPECT_TRUE(MatchPatternASCII(error, expected_error)) << name << + EXPECT_TRUE(MatchPattern(error, expected_error)) << name << " expected '" << expected_error << "' but got '" << error << "'"; } diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 2631d89..5f4f916 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -130,7 +130,7 @@ TEST(ExtensionTest, InitFromValueInvalid) { ASSERT_FALSE(NULL == icons); icons->SetInteger(base::IntToString(128), 42); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidIconPath)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidIconPath)); // Test invalid user scripts list input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -145,7 +145,7 @@ TEST(ExtensionTest, InitFromValueInvalid) { ASSERT_FALSE(NULL == content_scripts); content_scripts->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidContentScript)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidContentScript)); // Test missing and invalid matches array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -154,25 +154,25 @@ TEST(ExtensionTest, InitFromValueInvalid) { content_scripts->GetDictionary(0, &user_script); user_script->Remove(keys::kMatches, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatches)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatches)); user_script->Set(keys::kMatches, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatches)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatches)); ListValue* matches = new ListValue; user_script->Set(keys::kMatches, matches); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatchCount)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatchCount)); // Test invalid match element matches->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatch)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatch)); matches->Set(0, Value::CreateStringValue("chrome://*/*")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatch)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatch)); // Test missing and invalid files array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -181,40 +181,40 @@ TEST(ExtensionTest, InitFromValueInvalid) { user_script->Remove(keys::kJs, NULL); user_script->Remove(keys::kCss, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kMissingFile)); + EXPECT_TRUE(MatchPattern(error, errors::kMissingFile)); user_script->Set(keys::kJs, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidJsList)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidJsList)); user_script->Set(keys::kCss, new ListValue); user_script->Set(keys::kJs, new ListValue); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kMissingFile)); + EXPECT_TRUE(MatchPattern(error, errors::kMissingFile)); user_script->Remove(keys::kCss, NULL); ListValue* files = new ListValue; user_script->Set(keys::kJs, files); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kMissingFile)); + EXPECT_TRUE(MatchPattern(error, errors::kMissingFile)); // Test invalid file element files->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidJs)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidJs)); user_script->Remove(keys::kJs, NULL); // Test the css element user_script->Set(keys::kCss, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidCssList)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidCssList)); // Test invalid file element ListValue* css_files = new ListValue; user_script->Set(keys::kCss, css_files); css_files->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidCss)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidCss)); // Test missing and invalid permissions array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -229,17 +229,17 @@ TEST(ExtensionTest, InitFromValueInvalid) { input_value->Set(keys::kPermissions, Value::CreateIntegerValue(9)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermissions)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissions)); input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); input_value->GetList(keys::kPermissions, &permissions); permissions->Set(0, Value::CreateIntegerValue(24)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermission)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); permissions->Set(0, Value::CreateStringValue("www.google.com")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermission)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); // Multiple page actions are not allowed. input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -269,30 +269,30 @@ TEST(ExtensionTest, InitFromValueInvalid) { input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); input_value->Set(keys::kOptionsPage, Value::CreateNullValue()); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidOptionsPage)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidOptionsPage)); // Test invalid/empty default locale. input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); input_value->Set(keys::kDefaultLocale, Value::CreateIntegerValue(5)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidDefaultLocale)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidDefaultLocale)); input_value->Set(keys::kDefaultLocale, Value::CreateStringValue("")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidDefaultLocale)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidDefaultLocale)); // Test invalid minimum_chrome_version. input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); input_value->Set(keys::kMinimumChromeVersion, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMinimumChromeVersion)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidMinimumChromeVersion)); #if !defined(OS_MACOSX) // TODO(aa): The version isn't stamped into the unit test binary on mac. input_value->Set(keys::kMinimumChromeVersion, Value::CreateStringValue("88.8")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kChromeVersionTooLow)); + EXPECT_TRUE(MatchPattern(error, errors::kChromeVersionTooLow)); #endif } @@ -323,7 +323,7 @@ TEST(ExtensionTest, InitFromValueValid) { permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); input_value.Set(keys::kPermissions, permissions); EXPECT_FALSE(extension.InitFromValue(input_value, false, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermission)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); input_value.Remove(keys::kPermissions, NULL); error.clear(); @@ -684,7 +684,7 @@ TEST(ExtensionTest, UpdateUrls) { input_value.SetString(keys::kUpdateURL, invalid[i]); EXPECT_FALSE(extension.InitFromValue(input_value, false, &error)); - EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidUpdateURL)); + EXPECT_TRUE(MatchPattern(error, errors::kInvalidUpdateURL)); } } diff --git a/chrome/common/extensions/extension_unpacker_unittest.cc b/chrome/common/extensions/extension_unpacker_unittest.cc index 8cc769a..930c271 100644 --- a/chrome/common/extensions/extension_unpacker_unittest.cc +++ b/chrome/common/extensions/extension_unpacker_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -71,7 +71,7 @@ TEST_F(ExtensionUnpackerTest, InvalidDefaultLocale) { TEST_F(ExtensionUnpackerTest, InvalidMessagesFile) { SetupUnpacker("invalid_messages_file.crx"); EXPECT_FALSE(unpacker_->Run()); - EXPECT_TRUE(MatchPatternASCII(unpacker_->error_message(), + EXPECT_TRUE(MatchPattern(unpacker_->error_message(), std::string("*_locales?en_US?messages.json: Line: 2, column: 3," " Dictionary keys must be quoted."))); } @@ -92,7 +92,7 @@ TEST_F(ExtensionUnpackerTest, MissingDefaultLocaleHasLocalesFolder) { TEST_F(ExtensionUnpackerTest, MissingMessagesFile) { SetupUnpacker("missing_messages_file.crx"); EXPECT_FALSE(unpacker_->Run()); - EXPECT_TRUE(MatchPatternASCII(unpacker_->error_message(), + EXPECT_TRUE(MatchPattern(unpacker_->error_message(), errors::kLocalesMessagesFileMissing + std::string("*_locales?en_US?messages.json"))); } diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index 544376d..988988a 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -198,7 +198,7 @@ bool URLPattern::MatchesPath(const std::string& test) const { ReplaceSubstringsAfterOffset(&path_escaped_, 0, "?", "\\?"); } - if (!MatchPatternASCII(test, path_escaped_)) + if (!MatchPattern(test, path_escaped_)) return false; return true; diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h index 69fc393..b1cda15 100644 --- a/chrome/common/extensions/url_pattern.h +++ b/chrome/common/extensions/url_pattern.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ @@ -207,8 +207,8 @@ class URLPattern { std::string path_; // The path with "?" and "\" characters escaped for use with the - // MatchPatternASCII() function. This is populated lazily, the first time it - // is needed. + // MatchPattern() function. This is populated lazily, the first time it is + // needed. mutable std::string path_escaped_; }; diff --git a/chrome/common/extensions/user_script.cc b/chrome/common/extensions/user_script.cc index 2a40bec..cea7cf6 100644 --- a/chrome/common/extensions/user_script.cc +++ b/chrome/common/extensions/user_script.cc @@ -1,4 +1,4 @@ -// Copyright 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,7 +24,7 @@ bool UrlMatchesGlobs(const std::vector<std::string>* globs, const GURL& url) { for (std::vector<std::string>::const_iterator glob = globs->begin(); glob != globs->end(); ++glob) { - if (MatchPatternASCII(url.spec(), *glob)) + if (MatchPattern(url.spec(), *glob)) return true; } |