summaryrefslogtreecommitdiffstats
path: root/base/string_util.h
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-03 23:32:57 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-03 23:32:57 +0000
commitc5a7248b45656b1ca63f9ce35b60ca337f83d3d1 (patch)
tree0f6f50e96e99046d820d9b49ccea1294244b7c2a /base/string_util.h
parentdf2c7403503b45467d3d76ddc2f42296fa53ac50 (diff)
downloadchromium_src-c5a7248b45656b1ca63f9ce35b60ca337f83d3d1.zip
chromium_src-c5a7248b45656b1ca63f9ce35b60ca337f83d3d1.tar.gz
chromium_src-c5a7248b45656b1ca63f9ce35b60ca337f83d3d1.tar.bz2
Fixes to the string MatchPattern functions:
1) Make it explicit that it only supports ASCII (since it iterates character by character). 2) Limit the recursion to 16 levels. We could allow more, but in the case of a ?, it has exponential complexity, so I figured 16 was a good stopping point. It seems rare that someone would have more than 16 '?' and '*'s. BUG=28645 Review URL: http://codereview.chromium.org/460047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r--base/string_util.h7
1 files changed, 3 insertions, 4 deletions
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.