summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-10 08:18:46 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-10 08:18:46 +0000
commit4493574d71becba0ad1cbb74ce600466cc4f33e0 (patch)
treef50e1a49a49043de9e134087cb98f3b337fdf3b1
parenta15cbd47814d62163e2d66e64e7cb9e144fa5ca1 (diff)
downloadchromium_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
-rw-r--r--base/string_util.cc119
-rw-r--r--base/string_util.h4
-rw-r--r--base/string_util_unittest.cc44
-rw-r--r--base/third_party/icu/icu_utf.h30
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc8
-rw-r--r--chrome/browser/extensions/user_script_master.cc4
-rw-r--r--chrome/common/extensions/extension_manifests_unittest.cc2
-rw-r--r--chrome/common/extensions/extension_unittest.cc48
-rw-r--r--chrome/common/extensions/extension_unpacker_unittest.cc6
-rw-r--r--chrome/common/extensions/url_pattern.cc4
-rw-r--r--chrome/common/extensions/url_pattern.h6
-rw-r--r--chrome/common/extensions/user_script.cc4
-rw-r--r--chrome_frame/test/chrome_frame_ui_test_utils.cc6
-rw-r--r--chrome_frame/utils.cc3
-rw-r--r--net/base/host_mapping_rules.cc6
-rw-r--r--net/base/mock_host_resolver.cc2
-rw-r--r--net/proxy/proxy_bypass_rules.cc3
-rw-r--r--webkit/glue/webkit_glue.cc4
-rw-r--r--webkit/tools/test_shell/image_decoder_unittest.cc2
19 files changed, 192 insertions, 113 deletions
diff --git a/base/string_util.cc b/base/string_util.cc
index a7f5258..68f3d91 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -1038,102 +1038,116 @@ string16 ReplaceStringPlaceholders(const string16& format_string,
return result;
}
-template <class CHAR>
-static bool IsWildcard(CHAR character) {
+static bool IsWildcard(base_icu::UChar32 character) {
return character == '*' || character == '?';
}
// Move the strings pointers to the point where they start to differ.
-template <class CHAR>
-static void EatSameChars(const CHAR** pattern, const CHAR** string) {
- bool escaped = false;
- while (**pattern && **string) {
- if (!escaped && IsWildcard(**pattern)) {
+template <typename CHAR, typename NEXT>
+static void EatSameChars(const CHAR** pattern, const CHAR* pattern_end,
+ const CHAR** string, const CHAR* string_end,
+ NEXT next) {
+ const CHAR* escape = NULL;
+ while (*pattern != pattern_end && *string != string_end) {
+ if (!escape && IsWildcard(**pattern)) {
// We don't want to match wildcard here, except if it's escaped.
return;
}
// Check if the escapement char is found. If so, skip it and move to the
// next character.
- if (!escaped && **pattern == L'\\') {
- escaped = true;
- (*pattern)++;
+ if (!escape && **pattern == '\\') {
+ escape = *pattern;
+ next(pattern, pattern_end);
continue;
}
// Check if the chars match, if so, increment the ptrs.
- if (**pattern == **string) {
- (*pattern)++;
- (*string)++;
+ const CHAR* pattern_next = *pattern;
+ const CHAR* string_next = *string;
+ base_icu::UChar32 pattern_char = next(&pattern_next, pattern_end);
+ if (pattern_char == next(&string_next, string_end) &&
+ pattern_char != (base_icu::UChar32) CBU_SENTINEL) {
+ *pattern = pattern_next;
+ *string = string_next;
} else {
// Uh ho, it did not match, we are done. If the last char was an
// escapement, that means that it was an error to advance the ptr here,
// let's put it back where it was. This also mean that the MatchPattern
// function will return false because if we can't match an escape char
// here, then no one will.
- if (escaped) {
- (*pattern)--;
+ if (escape) {
+ *pattern = escape;
}
return;
}
- escaped = false;
+ escape = NULL;
}
}
-template <class CHAR>
-static void EatWildcard(const CHAR** pattern) {
- while (**pattern) {
+template <typename CHAR, typename NEXT>
+static void EatWildcard(const CHAR** pattern, const CHAR* end, NEXT next) {
+ while (*pattern != end) {
if (!IsWildcard(**pattern))
return;
- (*pattern)++;
+ next(pattern, end);
}
}
-template <class CHAR>
-static bool MatchPatternT(const CHAR* eval, const CHAR* pattern, int depth) {
+template <typename CHAR, typename NEXT>
+static bool MatchPatternT(const CHAR* eval, const CHAR* eval_end,
+ const CHAR* pattern, const CHAR* pattern_end,
+ int depth,
+ NEXT next) {
const int kMaxDepth = 16;
if (depth > kMaxDepth)
return false;
// Eat all the matching chars.
- EatSameChars(&pattern, &eval);
+ EatSameChars(&pattern, pattern_end, &eval, eval_end, next);
// If the string is empty, then the pattern must be empty too, or contains
// only wildcards.
- if (*eval == 0) {
- EatWildcard(&pattern);
- if (*pattern)
- return false;
- return true;
+ if (eval == eval_end) {
+ EatWildcard(&pattern, pattern_end, next);
+ return pattern == pattern_end;
}
// Pattern is empty but not string, this is not a match.
- if (*pattern == 0)
+ if (pattern == pattern_end)
return false;
// If this is a question mark, then we need to compare the rest with
// the current string or the string with one character eaten.
+ const CHAR* next_pattern = pattern;
+ next(&next_pattern, pattern_end);
if (pattern[0] == '?') {
- if (MatchPatternT(eval, pattern + 1, depth + 1) ||
- MatchPatternT(eval + 1, pattern + 1, depth + 1))
+ if (MatchPatternT(eval, eval_end, next_pattern, pattern_end,
+ depth + 1, next))
+ return true;
+ const CHAR* next_eval = eval;
+ next(&next_eval, eval_end);
+ if (MatchPatternT(next_eval, eval_end, next_pattern, pattern_end,
+ depth + 1, next))
return true;
}
// This is a *, try to match all the possible substrings with the remainder
// of the pattern.
if (pattern[0] == '*') {
- while (*eval) {
- if (MatchPatternT(eval, pattern + 1, depth + 1))
+ while (eval != eval_end) {
+ if (MatchPatternT(eval, eval_end, next_pattern, pattern_end,
+ depth + 1, next))
return true;
eval++;
}
// We reached the end of the string, let see if the pattern contains only
// wildcards.
- if (*eval == 0) {
- EatWildcard(&pattern);
- if (*pattern)
+ if (eval == eval_end) {
+ EatWildcard(&pattern, pattern_end, next);
+ if (pattern != pattern_end)
return false;
return true;
}
@@ -1142,13 +1156,36 @@ static bool MatchPatternT(const CHAR* eval, const CHAR* pattern, int depth) {
return false;
}
-bool MatchPatternWide(const std::wstring& eval, const std::wstring& pattern) {
- return MatchPatternT(eval.c_str(), pattern.c_str(), 0);
+struct NextCharUTF8 {
+ base_icu::UChar32 operator()(const char** p, const char* end) {
+ base_icu::UChar32 c;
+ int offset = 0;
+ CBU8_NEXT(*p, offset, end - *p, c);
+ *p += offset;
+ return c;
+ }
+};
+
+struct NextCharUTF16 {
+ base_icu::UChar32 operator()(const char16** p, const char16* end) {
+ base_icu::UChar32 c;
+ int offset = 0;
+ CBU16_NEXT(*p, offset, end - *p, c);
+ *p += offset;
+ return c;
+ }
+};
+
+bool MatchPattern(const std::string& eval, const std::string& pattern) {
+ return MatchPatternT(eval.c_str(), eval.c_str() + eval.size(),
+ pattern.c_str(), pattern.c_str() + pattern.size(),
+ 0, NextCharUTF8());
}
-bool MatchPatternASCII(const std::string& eval, const std::string& pattern) {
- DCHECK(IsStringASCII(eval) && IsStringASCII(pattern));
- return MatchPatternT(eval.c_str(), pattern.c_str(), 0);
+bool MatchPattern(const string16& eval, const string16& pattern) {
+ return MatchPatternT(eval.c_str(), eval.c_str() + eval.size(),
+ pattern.c_str(), pattern.c_str() + pattern.size(),
+ 0, NextCharUTF16());
}
// The following code is compatible with the OpenBSD lcpy interface. See:
diff --git a/base/string_util.h b/base/string_util.h
index 7788562..8370f8a 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -599,8 +599,8 @@ bool ElideString(const std::wstring& input, int max_len, std::wstring* output);
// string can contain wildcards like * and ?
// The backslash character (\) is an escape character for * and ?
// We limit the patterns to having a max of 16 * or ? characters.
-bool MatchPatternWide(const std::wstring& string, const std::wstring& pattern);
-bool MatchPatternASCII(const std::string& string, const std::string& pattern);
+bool MatchPattern(const std::string& string, const std::string& pattern);
+bool MatchPattern(const string16& string, const string16& pattern);
// Hack to convert any char-like type to its unsigned counterpart.
// For example, it will convert char, signed char and unsigned char to unsigned
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc
index f0524bee..23b1f53 100644
--- a/base/string_util_unittest.cc
+++ b/base/string_util_unittest.cc
@@ -1064,22 +1064,36 @@ TEST(StringUtilTest, SplitStringAlongWhitespace) {
}
TEST(StringUtilTest, MatchPatternTest) {
- EXPECT_EQ(MatchPatternASCII("www.google.com", "*.com"), true);
- EXPECT_EQ(MatchPatternASCII("www.google.com", "*"), true);
- EXPECT_EQ(MatchPatternASCII("www.google.com", "www*.g*.org"), false);
- EXPECT_EQ(MatchPatternASCII("Hello", "H?l?o"), true);
- EXPECT_EQ(MatchPatternASCII("www.google.com", "http://*)"), false);
- EXPECT_EQ(MatchPatternASCII("www.msn.com", "*.COM"), false);
- EXPECT_EQ(MatchPatternASCII("Hello*1234", "He??o\\*1*"), true);
- EXPECT_EQ(MatchPatternASCII("", "*.*"), false);
- EXPECT_EQ(MatchPatternASCII("", "*"), true);
- EXPECT_EQ(MatchPatternASCII("", "?"), true);
- EXPECT_EQ(MatchPatternASCII("", ""), true);
- EXPECT_EQ(MatchPatternASCII("Hello", ""), false);
- EXPECT_EQ(MatchPatternASCII("Hello*", "Hello*"), true);
+ EXPECT_TRUE(MatchPattern("www.google.com", "*.com"));
+ EXPECT_TRUE(MatchPattern("www.google.com", "*"));
+ EXPECT_FALSE(MatchPattern("www.google.com", "www*.g*.org"));
+ EXPECT_TRUE(MatchPattern("Hello", "H?l?o"));
+ EXPECT_FALSE(MatchPattern("www.google.com", "http://*)"));
+ EXPECT_FALSE(MatchPattern("www.msn.com", "*.COM"));
+ EXPECT_TRUE(MatchPattern("Hello*1234", "He??o\\*1*"));
+ EXPECT_FALSE(MatchPattern("", "*.*"));
+ EXPECT_TRUE(MatchPattern("", "*"));
+ EXPECT_TRUE(MatchPattern("", "?"));
+ EXPECT_TRUE(MatchPattern("", ""));
+ EXPECT_FALSE(MatchPattern("Hello", ""));
+ EXPECT_TRUE(MatchPattern("Hello*", "Hello*"));
// Stop after a certain recursion depth.
- EXPECT_EQ(MatchPatternASCII("12345678901234567890", "???????????????????*"),
- false);
+ EXPECT_FALSE(MatchPattern("123456789012345678", "?????????????????*"));
+
+ // Test UTF8 matching.
+ EXPECT_TRUE(MatchPattern("heart: \xe2\x99\xa0", "*\xe2\x99\xa0"));
+ EXPECT_TRUE(MatchPattern("heart: \xe2\x99\xa0.", "heart: ?."));
+ EXPECT_TRUE(MatchPattern("hearts: \xe2\x99\xa0\xe2\x99\xa0", "*"));
+ // Invalid sequences should be handled as a single invalid character.
+ EXPECT_TRUE(MatchPattern("invalid: \xef\xbf\xbe", "invalid: ?"));
+ // If the pattern has invalid characters, it shouldn't match anything.
+ EXPECT_FALSE(MatchPattern("\xf4\x90\x80\x80", "\xf4\x90\x80\x80"));
+
+ // Test UTF16 character matching.
+ EXPECT_TRUE(MatchPattern(UTF8ToUTF16("www.google.com"),
+ UTF8ToUTF16("*.com")));
+ EXPECT_TRUE(MatchPattern(UTF8ToUTF16("Hello*1234"),
+ UTF8ToUTF16("He??o\\*1*")));
}
TEST(StringUtilTest, LcpyTest) {
diff --git a/base/third_party/icu/icu_utf.h b/base/third_party/icu/icu_utf.h
index 4d63eca..43b4967 100644
--- a/base/third_party/icu/icu_utf.h
+++ b/base/third_party/icu/icu_utf.h
@@ -332,6 +332,36 @@ UChar32 utf8_nextCharSafeBody(const uint8 *s, int32 *pi, int32 length, UChar32 c
#define CBU16_MAX_LENGTH 2
/**
+ * Get a code point from a string at a code point boundary offset,
+ * and advance the offset to the next code point boundary.
+ * (Post-incrementing forward iteration.)
+ * "Safe" macro, handles unpaired surrogates and checks for string boundaries.
+ *
+ * The offset may point to the lead surrogate unit
+ * for a supplementary code point, in which case the macro will read
+ * the following trail surrogate as well.
+ * If the offset points to a trail surrogate or
+ * to a single, unpaired lead surrogate, then that itself
+ * will be returned as the code point.
+ *
+ * @param s const UChar * string
+ * @param i string offset, i<length
+ * @param length string length
+ * @param c output UChar32 variable
+ * @stable ICU 2.4
+ */
+#define CBU16_NEXT(s, i, length, c) { \
+ (c)=(s)[(i)++]; \
+ if(CBU16_IS_LEAD(c)) { \
+ uint16 __c2; \
+ if((i)<(length) && CBU16_IS_TRAIL(__c2=(s)[(i)])) { \
+ ++(i); \
+ (c)=CBU16_GET_SUPPLEMENTARY((c), __c2); \
+ } \
+ } \
+}
+
+/**
* Append a code point to a string, overwriting 1 or 2 code units.
* The offset points to the current end of the string contents
* and is advanced (post-increment).
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index 5e64b79..fa3b1b4 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -806,19 +806,19 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectoryFail) {
ASSERT_EQ(4u, GetErrors().size());
ASSERT_EQ(0u, loaded_.size());
- EXPECT_TRUE(MatchPatternASCII(GetErrors()[0],
+ EXPECT_TRUE(MatchPattern(GetErrors()[0],
std::string("Could not load extension from '*'. ") +
extension_manifest_errors::kManifestUnreadable)) << GetErrors()[0];
- EXPECT_TRUE(MatchPatternASCII(GetErrors()[1],
+ EXPECT_TRUE(MatchPattern(GetErrors()[1],
std::string("Could not load extension from '*'. ") +
extension_manifest_errors::kManifestUnreadable)) << GetErrors()[1];
- EXPECT_TRUE(MatchPatternASCII(GetErrors()[2],
+ EXPECT_TRUE(MatchPattern(GetErrors()[2],
std::string("Could not load extension from '*'. ") +
extension_manifest_errors::kMissingFile)) << GetErrors()[2];
- EXPECT_TRUE(MatchPatternASCII(GetErrors()[3],
+ EXPECT_TRUE(MatchPattern(GetErrors()[3],
std::string("Could not load extension from '*'. ") +
extension_manifest_errors::kManifestUnreadable)) << GetErrors()[3];
};
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index 2f2ced5..02aa9e0 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 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.
@@ -88,7 +88,7 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader(
std::string value;
if (GetDeclarationValue(line, kIncludeDeclaration, &value)) {
- // We escape some characters that MatchPatternASCII() considers special.
+ // We escape some characters that MatchPattern() considers special.
ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\");
ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?");
script->add_glob(value);
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;
}
diff --git a/chrome_frame/test/chrome_frame_ui_test_utils.cc b/chrome_frame/test/chrome_frame_ui_test_utils.cc
index 3ff61f7..b0ff727 100644
--- a/chrome_frame/test/chrome_frame_ui_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_ui_test_utils.cc
@@ -489,15 +489,15 @@ bool AccObjectMatcher::DoesMatch(AccObject* object) const {
std::wstring name, role_text, value;
if (name_.length()) {
object->GetName(&name);
- does_match = MatchPatternWide(name, name_);
+ does_match = MatchPattern(name, name_);
}
if (does_match && role_text_.length()) {
object->GetRoleText(&role_text);
- does_match = MatchPatternWide(role_text, role_text_);
+ does_match = MatchPattern(role_text, role_text_);
}
if (does_match && value_.length()) {
object->GetValue(&value);
- does_match = MatchPatternWide(value, value_);
+ does_match = MatchPattern(value, value_);
}
return does_match;
}
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index 887d13d..8526b9a 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -719,7 +719,7 @@ bool IsOptInUrl(const wchar_t* url) {
bool match_found = false;
RegistryValueIterator url_list(config_key.Handle(), url_list_name);
while (!match_found && url_list.Valid()) {
- if (MatchPatternWide(url, url_list.Name())) {
+ if (MatchPattern(url, url_list.Name())) {
match_found = true;
} else {
++url_list;
@@ -1437,4 +1437,3 @@ void PinModule() {
}
}
}
-
diff --git a/net/base/host_mapping_rules.cc b/net/base/host_mapping_rules.cc
index 56b9694..a535d14 100644
--- a/net/base/host_mapping_rules.cc
+++ b/net/base/host_mapping_rules.cc
@@ -19,7 +19,7 @@ bool HostMappingRules::RewriteHost(HostPortPair* host_port) const {
for (ExclusionRuleList::const_iterator it = exclusion_rules_.begin();
it != exclusion_rules_.end(); ++it) {
const ExclusionRule& rule = *it;
- if (MatchPatternASCII(host_port->host(), rule.hostname_pattern))
+ if (MatchPattern(host_port->host(), rule.hostname_pattern))
return false;
}
@@ -35,9 +35,9 @@ bool HostMappingRules::RewriteHost(HostPortPair* host_port) const {
// *.foo.com:1234
// First, we'll check for a match just on hostname.
// If that fails, we'll check for a match with both hostname and port.
- if (!MatchPatternASCII(host_port->host(), rule.hostname_pattern)) {
+ if (!MatchPattern(host_port->host(), rule.hostname_pattern)) {
std::string host_port_string = host_port->ToString();
- if (!MatchPatternASCII(host_port_string, rule.hostname_pattern))
+ if (!MatchPattern(host_port_string, rule.hostname_pattern))
continue; // This rule doesn't apply.
}
diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc
index 8c2a9a4..f8c53a6 100644
--- a/net/base/mock_host_resolver.cc
+++ b/net/base/mock_host_resolver.cc
@@ -227,7 +227,7 @@ int RuleBasedHostResolverProc::Resolve(const std::string& host,
bool matches_flags = (r->host_resolver_flags & host_resolver_flags) ==
host_resolver_flags;
if (matches_flags && matches_address_family &&
- MatchPatternASCII(host, r->host_pattern)) {
+ MatchPattern(host, r->host_pattern)) {
if (r->latency_ms != 0)
PlatformThread::Sleep(r->latency_ms);
diff --git a/net/proxy/proxy_bypass_rules.cc b/net/proxy/proxy_bypass_rules.cc
index 987543a..757d817 100644
--- a/net/proxy/proxy_bypass_rules.cc
+++ b/net/proxy/proxy_bypass_rules.cc
@@ -32,8 +32,7 @@ class HostnamePatternRule : public ProxyBypassRules::Rule {
// Note it is necessary to lower-case the host, since GURL uses capital
// letters for percent-escaped characters.
- return MatchPatternASCII(StringToLowerASCII(url.host()),
- hostname_pattern_);
+ return MatchPattern(StringToLowerASCII(url.host()), hostname_pattern_);
}
virtual std::string ToString() const {
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index e525be9..53f238f 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.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.
@@ -354,7 +354,7 @@ const std::string& GetUserAgent(const GURL& url) {
if (!g_user_agent->user_agent_is_overridden) {
// Workarounds for sites that use misguided UA sniffing.
#if defined(OS_POSIX) && !defined(OS_MACOSX)
- if (MatchPatternASCII(url.host(), "*.mail.yahoo.com")) {
+ if (MatchPattern(url.host(), "*.mail.yahoo.com")) {
// mail.yahoo.com is ok with Windows Chrome but not Linux Chrome.
// http://bugs.chromium.org/11136
// TODO(evanm): remove this if Yahoo fixes their sniffing.
diff --git a/webkit/tools/test_shell/image_decoder_unittest.cc b/webkit/tools/test_shell/image_decoder_unittest.cc
index 1ca545e..8d4c75d 100644
--- a/webkit/tools/test_shell/image_decoder_unittest.cc
+++ b/webkit/tools/test_shell/image_decoder_unittest.cc
@@ -126,7 +126,7 @@ std::vector<FilePath> ImageDecoderTest::GetImageFiles() const {
#else
std::string base_name_ascii = base_name.value();
#endif
- if (!MatchPatternASCII(base_name_ascii, pattern))
+ if (!MatchPattern(base_name_ascii, pattern))
continue;
image_files.push_back(next_file_name);
}