diff options
-rw-r--r-- | base/string_util.cc | 21 | ||||
-rw-r--r-- | base/string_util.h | 7 | ||||
-rw-r--r-- | base/string_util_unittest.cc | 30 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_file_util_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/user_script_master.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unittest.cc | 44 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unpacker_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/url_pattern.h | 4 | ||||
-rw-r--r-- | chrome/common/extensions/user_script.cc | 2 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 2 | ||||
-rw-r--r-- | net/base/mock_host_resolver.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_config.cc | 3 | ||||
-rw-r--r-- | net/proxy/proxy_service.cc | 2 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.cc | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/image_decoder_unittest.cc | 13 |
17 files changed, 81 insertions, 73 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index 01a6907..9db0f03 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -1561,7 +1561,11 @@ static void EatWildcard(const CHAR** pattern) { } template <class CHAR> -static bool MatchPatternT(const CHAR* eval, const CHAR* pattern) { +static bool MatchPatternT(const CHAR* eval, const CHAR* pattern, int depth) { + const int kMaxDepth = 16; + if (depth > kMaxDepth) + return false; + // Eat all the matching chars. EatSameChars(&pattern, &eval); @@ -1581,8 +1585,8 @@ static bool MatchPatternT(const CHAR* eval, const CHAR* pattern) { // If this is a question mark, then we need to compare the rest with // the current string or the string with one character eaten. if (pattern[0] == '?') { - if (MatchPatternT(eval, pattern + 1) || - MatchPatternT(eval + 1, pattern + 1)) + if (MatchPatternT(eval, pattern + 1, depth + 1) || + MatchPatternT(eval + 1, pattern + 1, depth + 1)) return true; } @@ -1590,7 +1594,7 @@ static bool MatchPatternT(const CHAR* eval, const CHAR* pattern) { // of the pattern. if (pattern[0] == '*') { while (*eval) { - if (MatchPatternT(eval, pattern + 1)) + if (MatchPatternT(eval, pattern + 1, depth + 1)) return true; eval++; } @@ -1608,12 +1612,13 @@ static bool MatchPatternT(const CHAR* eval, const CHAR* pattern) { return false; } -bool MatchPattern(const std::wstring& eval, const std::wstring& pattern) { - return MatchPatternT(eval.c_str(), pattern.c_str()); +bool MatchPatternWide(const std::wstring& eval, const std::wstring& pattern) { + return MatchPatternT(eval.c_str(), pattern.c_str(), 0); } -bool MatchPattern(const std::string& eval, const std::string& pattern) { - return MatchPatternT(eval.c_str(), pattern.c_str()); +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 StringToInt(const std::string& input, int* output) { diff --git a/base/string_util.h b/base/string_util.h index dec39a6..66518e9 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -590,11 +590,10 @@ bool ElideString(const std::wstring& input, int max_len, std::wstring* output); // Returns true if the string passed in matches the pattern. The pattern // string can contain wildcards like * and ? -// TODO(iyengar) This function may not work correctly for CJK strings as -// it does individual character matches. // The backslash character (\) is an escape character for * and ? -bool MatchPattern(const std::wstring& string, const std::wstring& pattern); -bool MatchPattern(const std::string& string, const std::string& pattern); +// 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); // Returns a hex string representation of a binary buffer. // The returned hex string will be in upper case. diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index c586ff4..76dafa3 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -1212,20 +1212,22 @@ TEST(StringUtilTest, SplitStringAlongWhitespace) { } TEST(StringUtilTest, MatchPatternTest) { - EXPECT_EQ(MatchPattern(L"www.google.com", L"*.com"), true); - EXPECT_EQ(MatchPattern(L"www.google.com", L"*"), true); - EXPECT_EQ(MatchPattern(L"www.google.com", L"www*.g*.org"), false); - EXPECT_EQ(MatchPattern(L"Hello", L"H?l?o"), true); - EXPECT_EQ(MatchPattern(L"www.google.com", L"http://*)"), false); - EXPECT_EQ(MatchPattern(L"www.msn.com", L"*.COM"), false); - EXPECT_EQ(MatchPattern(L"Hello*1234", L"He??o\\*1*"), true); - EXPECT_EQ(MatchPattern(L"", L"*.*"), false); - EXPECT_EQ(MatchPattern(L"", L"*"), true); - EXPECT_EQ(MatchPattern(L"", L"?"), true); - EXPECT_EQ(MatchPattern(L"", L""), true); - EXPECT_EQ(MatchPattern(L"Hello", L""), false); - EXPECT_EQ(MatchPattern(L"Hello*", L"Hello*"), true); - EXPECT_EQ(MatchPattern("Hello*", "Hello*"), true); // narrow string + 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); + // Stop after a certain recursion depth. + EXPECT_EQ(MatchPatternASCII("12345678901234567890", "???????????????????*"), + false); } TEST(StringUtilTest, LcpyTest) { diff --git a/chrome/browser/extensions/extension_file_util_unittest.cc b/chrome/browser/extensions/extension_file_util_unittest.cc index 6e00eb0..4184272 100644 --- a/chrome/browser/extensions/extension_file_util_unittest.cc +++ b/chrome/browser/extensions/extension_file_util_unittest.cc @@ -233,7 +233,7 @@ TEST(ExtensionFileUtil, MissingPrivacyBlacklist) { extension_file_util::LoadExtension(install_dir, false, &error)); ASSERT_TRUE(extension == NULL); ASSERT_FALSE(error.empty()); - EXPECT_TRUE(MatchPattern(error, + EXPECT_TRUE(MatchPatternASCII(error, "Could not load '*privacy_blacklist.pbl' for privacy blacklist: " "file does not exist.")) << error; } @@ -250,7 +250,7 @@ TEST(ExtensionFileUtil, InvalidPrivacyBlacklist) { extension_file_util::LoadExtension(install_dir, false, &error)); ASSERT_TRUE(extension == NULL); ASSERT_FALSE(error.empty()); - EXPECT_TRUE(MatchPattern(error, + EXPECT_TRUE(MatchPatternASCII(error, "Could not load '*privacy_blacklist.pbl' for privacy blacklist: " "Incorrect header.")) << error; } diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 12b11cf..bccc0ac 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -624,19 +624,19 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectoryFail) { ASSERT_EQ(4u, GetErrors().size()); ASSERT_EQ(0u, loaded_.size()); - EXPECT_TRUE(MatchPattern(GetErrors()[0], + EXPECT_TRUE(MatchPatternASCII(GetErrors()[0], std::string("Could not load extension from '*'. ") + extension_manifest_errors::kManifestUnreadable)) << GetErrors()[0]; - EXPECT_TRUE(MatchPattern(GetErrors()[1], + EXPECT_TRUE(MatchPatternASCII(GetErrors()[1], std::string("Could not load extension from '*'. ") + extension_manifest_errors::kManifestUnreadable)) << GetErrors()[1]; - EXPECT_TRUE(MatchPattern(GetErrors()[2], + EXPECT_TRUE(MatchPatternASCII(GetErrors()[2], std::string("Could not load extension from '*'. ") + extension_manifest_errors::kMissingFile)) << GetErrors()[2]; - EXPECT_TRUE(MatchPattern(GetErrors()[3], + EXPECT_TRUE(MatchPatternASCII(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 a485a41..06ec0c5 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -84,7 +84,7 @@ bool UserScriptMaster::ScriptReloader::ParseMetadataHeader( std::string value; if (GetDeclarationValue(line, kIncludeDeclaration, &value)) { - // We escape some characters that MatchPattern() considers special. + // We escape some characters that MatchPatternASCII() considers special. ReplaceSubstringsAfterOffset(&value, 0, "\\", "\\\\"); ReplaceSubstringsAfterOffset(&value, 0, "?", "\\?"); script->add_glob(value); diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc index 330478c..894d5be 100644 --- a/chrome/common/extensions/extension_unittest.cc +++ b/chrome/common/extensions/extension_unittest.cc @@ -94,7 +94,7 @@ TEST(ExtensionTest, DISABLED_InitFromValueInvalid) { ASSERT_FALSE(NULL == icons); icons->SetInteger(ASCIIToWide(IntToString(128)), 42); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidIconPath)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidIconPath)); // Test invalid user scripts list input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -109,7 +109,7 @@ TEST(ExtensionTest, DISABLED_InitFromValueInvalid) { ASSERT_FALSE(NULL == content_scripts); content_scripts->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidContentScript)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidContentScript)); // Test missing and invalid matches array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -118,21 +118,21 @@ TEST(ExtensionTest, DISABLED_InitFromValueInvalid) { content_scripts->GetDictionary(0, &user_script); user_script->Remove(keys::kMatches, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatches)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatches)); user_script->Set(keys::kMatches, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatches)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatches)); ListValue* matches = new ListValue; user_script->Set(keys::kMatches, matches); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatchCount)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatchCount)); // Test invalid match element matches->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatch)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidMatch)); // Test missing and invalid files array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -141,40 +141,40 @@ TEST(ExtensionTest, DISABLED_InitFromValueInvalid) { user_script->Remove(keys::kJs, NULL); user_script->Remove(keys::kCss, NULL); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kMissingFile)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kMissingFile)); user_script->Set(keys::kJs, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidJsList)); + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(error, errors::kMissingFile)); + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(error, errors::kMissingFile)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kMissingFile)); // Test invalid file element files->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidJs)); + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(error, errors::kInvalidCssList)); + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(error, errors::kInvalidCss)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidCss)); // Test missing and invalid permissions array input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -190,24 +190,24 @@ TEST(ExtensionTest, DISABLED_InitFromValueInvalid) { input_value->Set(keys::kPermissions, Value::CreateIntegerValue(9)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissions)); + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(error, errors::kInvalidPermission)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermission)); permissions->Set(0, Value::CreateStringValue("www.google.com")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermission)); // Test permissions scheme. input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); input_value->GetList(keys::kPermissions, &permissions); permissions->Set(0, Value::CreateStringValue("file:///C:/foo.txt")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissionScheme)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPermissionScheme)); // Test invalid privacy blacklists list. input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -222,7 +222,7 @@ TEST(ExtensionTest, DISABLED_InitFromValueInvalid) { ASSERT_FALSE(NULL == privacy_blacklists); privacy_blacklists->Set(0, Value::CreateIntegerValue(42)); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidPrivacyBlacklistsPath)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidPrivacyBlacklistsPath)); // Test invalid UI surface count (both page action and browser action). input_value.reset(static_cast<DictionaryValue*>(valid_value->DeepCopy())); @@ -240,17 +240,17 @@ TEST(ExtensionTest, DISABLED_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(MatchPattern(error, errors::kInvalidOptionsPage)); + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(error, errors::kInvalidDefaultLocale)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidDefaultLocale)); input_value->Set(keys::kDefaultLocale, Value::CreateStringValue("")); EXPECT_FALSE(extension.InitFromValue(*input_value, true, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidDefaultLocale)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidDefaultLocale)); } TEST(ExtensionTest, InitFromValueValid) { @@ -511,7 +511,7 @@ TEST(ExtensionTest, UpdateUrls) { input_value.SetString(keys::kUpdateURL, invalid[i]); EXPECT_FALSE(extension.InitFromValue(input_value, false, &error)); - EXPECT_TRUE(MatchPattern(error, errors::kInvalidUpdateURL)); + EXPECT_TRUE(MatchPatternASCII(error, errors::kInvalidUpdateURL)); } } diff --git a/chrome/common/extensions/extension_unpacker_unittest.cc b/chrome/common/extensions/extension_unpacker_unittest.cc index 747827d..362db24 100644 --- a/chrome/common/extensions/extension_unpacker_unittest.cc +++ b/chrome/common/extensions/extension_unpacker_unittest.cc @@ -71,7 +71,7 @@ TEST_F(ExtensionUnpackerTest, InvalidDefaultLocale) { TEST_F(ExtensionUnpackerTest, InvalidMessagesFile) { SetupUnpacker("invalid_messages_file.crx"); EXPECT_FALSE(unpacker_->Run()); - EXPECT_TRUE(MatchPattern(unpacker_->error_message(), + EXPECT_TRUE(MatchPatternASCII(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(MatchPattern(unpacker_->error_message(), + EXPECT_TRUE(MatchPatternASCII(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 b3a5e80..ee40c54 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -131,7 +131,7 @@ bool URLPattern::MatchesPath(const GURL& test) const { ReplaceSubstringsAfterOffset(&path_escaped_, 0, "?", "\\?"); } - if (!MatchPattern(test.PathForRequest(), path_escaped_)) + if (!MatchPatternASCII(test.PathForRequest(), path_escaped_)) return false; return true; diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h index d952216..6b020c47 100644 --- a/chrome/common/extensions/url_pattern.h +++ b/chrome/common/extensions/url_pattern.h @@ -125,8 +125,8 @@ class URLPattern { std::string path_; // The path with "?" and "\" characters escaped for use with the - // MatchPattern() function. This is populated lazily, the first time it is - // needed. + // MatchPatternASCII() 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 96f7dd4..7a48c14 100644 --- a/chrome/common/extensions/user_script.cc +++ b/chrome/common/extensions/user_script.cc @@ -23,7 +23,7 @@ static 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 (MatchPattern(url.spec(), *glob)) + if (MatchPatternASCII(url.spec(), *glob)) return true; } diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 10bf92a..dd7ea8b 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -552,7 +552,7 @@ bool IsOptInUrl(const wchar_t* url) { RegistryValueIterator optin_urls_list(config_key.Handle(), kChromeFrameOptinUrlsKey); while (optin_urls_list.Valid()) { - if (MatchPattern(url, optin_urls_list.Name())) + if (MatchPatternWide(url, optin_urls_list.Name())) return true; ++optin_urls_list; } diff --git a/net/base/mock_host_resolver.cc b/net/base/mock_host_resolver.cc index 46772b3..a17ac80 100644 --- a/net/base/mock_host_resolver.cc +++ b/net/base/mock_host_resolver.cc @@ -189,7 +189,7 @@ int RuleBasedHostResolverProc::Resolve(const std::string& host, r->address_family == ADDRESS_FAMILY_UNSPECIFIED || r->address_family == address_family; - if (matches_address_family && MatchPattern(host, r->host_pattern)) { + if (matches_address_family && MatchPatternASCII(host, r->host_pattern)) { if (r->latency_ms != 0) PlatformThread::Sleep(r->latency_ms); diff --git a/net/proxy/proxy_config.cc b/net/proxy/proxy_config.cc index a1aa92c..836559e 100644 --- a/net/proxy/proxy_config.cc +++ b/net/proxy/proxy_config.cc @@ -121,7 +121,8 @@ void ProxyConfig::ParseNoProxyList(const std::string& no_proxy) { // A single "*" is specifically allowed and unproxies anything. // "*" wildcards other than a single "*" entry are not universally // supported. We will support them, as we get * wildcards for free - // (see MatchPattern() called from ProxyService::ShouldBypassProxyForURL()). + // (see MatchPatternASCII() called from + // ProxyService::ShouldBypassProxyForURL()). // no_proxy is a comma-separated list of <trailing_domain>[:<port>]. // If no port is specified then any port matches. // The historical definition has trailing_domain match using a simple diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index dc97d47..7acde10 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -740,7 +740,7 @@ bool ProxyService::ShouldBypassProxyForURL(const GURL& url) { StringToLowerASCII(&bypass_url_domain); - if (MatchPattern(*url_compare_reference, bypass_url_domain)) + if (MatchPatternASCII(*url_compare_reference, bypass_url_domain)) return true; // Some systems (the Mac, for example) allow CIDR-style specification of diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index c822040..0b3c39b 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -489,7 +489,7 @@ const std::string& GetUserAgent(const GURL& url) { g_user_agent->user_agent_requested = true; if (!g_user_agent->user_agent_is_overridden) { // Workarounds for sites that use misguided UA sniffing. - if (MatchPattern(url.host(), "*.pointroll.com")) { + if (MatchPatternASCII(url.host(), "*.pointroll.com")) { // For cnn.com, which uses pointroll.com to serve their front door promo, // we must spoof Chrome 1.0 in order to avoid a blank page. // http://crbug.com/25934 @@ -500,7 +500,7 @@ const std::string& GetUserAgent(const GURL& url) { return g_user_agent->mimic_chrome1_user_agent; } #if defined(OS_LINUX) - else if (MatchPattern(url.host(), "*.mail.yahoo.com")) { + else if (MatchPatternASCII(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 87af6df..7384ff30 100644 --- a/webkit/tools/test_shell/image_decoder_unittest.cc +++ b/webkit/tools/test_shell/image_decoder_unittest.cc @@ -112,11 +112,7 @@ void ImageDecoderTest::SetUp() { } std::vector<FilePath> ImageDecoderTest::GetImageFiles() const { -#if defined(OS_WIN) - std::wstring pattern = ASCIIToWide("*." + format_); -#else std::string pattern = "*." + format_; -#endif file_util::FileEnumerator enumerator(data_dir_, false, @@ -125,9 +121,14 @@ std::vector<FilePath> ImageDecoderTest::GetImageFiles() const { std::vector<FilePath> image_files; FilePath next_file_name; while (!(next_file_name = enumerator.Next()).empty()) { - if (!MatchPattern(next_file_name.value(), pattern)) { + FilePath base_name = next_file_name.BaseName(); +#if defined(OS_WIN) + std::string base_name_ascii = WideToASCII(base_name.value()); +#else + std::string base_name_ascii = base_name.value(); +#endif + if (!MatchPatternASCII(base_name_ascii, pattern)) continue; - } image_files.push_back(next_file_name); } |