summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 21:57:51 +0000
committersreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-07 21:57:51 +0000
commit2f4c21d1fb3fd6cb7eeec0a69b95970dcb7f3180 (patch)
tree4a0b531095e8b31b7a8d956bf970a776319ea349
parent72c5bcfbd65e46fa613fec3a2b04923a59029959 (diff)
downloadchromium_src-2f4c21d1fb3fd6cb7eeec0a69b95970dcb7f3180.zip
chromium_src-2f4c21d1fb3fd6cb7eeec0a69b95970dcb7f3180.tar.gz
chromium_src-2f4c21d1fb3fd6cb7eeec0a69b95970dcb7f3180.tar.bz2
Ensure URL suggestions are valid.
BUG=159293 R=mathp@chromium.org TEST=Steps to reproduce (see bug) shouldn't cause a crash anymore. Review URL: https://codereview.chromium.org/11275175 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166531 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/instant/instant_controller.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 06381c7..25b43ff 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -578,9 +578,13 @@ void InstantController::SetSuggestions(
// Suggestion text should be a full URL for URL suggestions, or the
// completion of a query for query suggestions.
if (suggestion.type == INSTANT_SUGGESTION_URL) {
- if (!StartsWith(suggestion.text, ASCIIToUTF16("http://"), false) &&
- !StartsWith(suggestion.text, ASCIIToUTF16("https://"), false))
- suggestion.text = ASCIIToUTF16("http://") + suggestion.text;
+ // If the suggestion is not a valid URL, perhaps it's something like
+ // "foo.com". Try prefixing "http://". If it still isn't valid, drop it.
+ if (!GURL(suggestion.text).is_valid()) {
+ suggestion.text.insert(0, ASCIIToUTF16("http://"));
+ if (!GURL(suggestion.text).is_valid())
+ suggestion = InstantSuggestion();
+ }
} else if (StartsWith(suggestion.text, last_user_text_, true)) {
// The user typed an exact prefix of the suggestion.
suggestion.text.erase(0, last_user_text_.size());
@@ -590,7 +594,7 @@ void InstantController::SetSuggestions(
// for instance, if the user types 'i' and the suggestion is 'INSTANT',
// suggestion 'nstant'. Otherwise, the user text really isn't a prefix,
// so suggest nothing.
- suggestion.text.clear();
+ suggestion = InstantSuggestion();
}
last_suggestion_ = suggestion;