summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/query_parser.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 23:06:03 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-26 23:06:03 +0000
commit7879f719399152a9802d2fc0c82d7d1a8e38aa4f (patch)
tree57011c38b4c364a1b2b7cf40ffb4a58deca8af93 /chrome/browser/history/query_parser.cc
parent8a8da5ac194e723260061b2fed14e0ac0e343642 (diff)
downloadchromium_src-7879f719399152a9802d2fc0c82d7d1a8e38aa4f.zip
chromium_src-7879f719399152a9802d2fc0c82d7d1a8e38aa4f.tar.gz
chromium_src-7879f719399152a9802d2fc0c82d7d1a8e38aa4f.tar.bz2
Temporary fix to avoid crash in typing in Omnibox. The crash happens
if you have a lower case string that is longer than the mixed case string and we get a match at the end of the string. This crashed because the offset is now past the end of the string. This fix is temporary in that it avoids the crash by not highlighting a match in the string. The right fix will be better parsing so we correctly recognize how the two strings line up, but that'll happen later. BUG=9335 TEST=Create a bookmark with the title on the page http://www.google.com/support/forum/p/Chrome/thread?fid=3b64f0cdd1e29e94000466022c425763&hl=en , then type in i and make sure we don't crash. This is also covered by unit tests now, so don't feel you need to test it. Review URL: http://codereview.chromium.org/42664 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/query_parser.cc')
-rw-r--r--chrome/browser/history/query_parser.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/history/query_parser.cc b/chrome/browser/history/query_parser.cc
index cb9cf40..3f80f7f 100644
--- a/chrome/browser/history/query_parser.cc
+++ b/chrome/browser/history/query_parser.cc
@@ -301,7 +301,8 @@ bool QueryParser::DoesQueryMatch(const std::wstring& text,
return false;
std::vector<QueryWord> query_words;
- ExtractQueryWords(l10n_util::ToLower(text), &query_words);
+ std::wstring lower_text = l10n_util::ToLower(text);
+ ExtractQueryWords(lower_text, &query_words);
if (query_words.empty())
return false;
@@ -311,8 +312,16 @@ bool QueryParser::DoesQueryMatch(const std::wstring& text,
if (!query_nodes[i]->HasMatchIn(query_words, &matches))
return false;
}
- CoalseAndSortMatchPositions(&matches);
- match_positions->swap(matches);
+ if (lower_text.length() != text.length()) {
+ // The lower case string differs from the original string. The matches are
+ // meaningless.
+ // TODO(sky): we need a better way to align the positions so that we don't
+ // completely punt here.
+ match_positions->clear();
+ } else {
+ CoalseAndSortMatchPositions(&matches);
+ match_positions->swap(matches);
+ }
return true;
}