diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 18:57:45 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 18:57:45 +0000 |
commit | 16afe22aab8965a3783aaba4f16fb7239218bdd1 (patch) | |
tree | 7232dbe30ef6cab9ab18a2abf4df802a232e3b1b /chrome/browser/autocomplete/search_provider.cc | |
parent | ca5e4493e3ee94e008afd6a22ef87881b936cf5e (diff) | |
download | chromium_src-16afe22aab8965a3783aaba4f16fb7239218bdd1.zip chromium_src-16afe22aab8965a3783aaba4f16fb7239218bdd1.tar.gz chromium_src-16afe22aab8965a3783aaba4f16fb7239218bdd1.tar.bz2 |
Fixup and verify URLs from the server before adding them to the autocomplete dropdown.
Original patch by Brian Duff, r=me (see http://codereview.chromium.org/16503 ), tweaked some.
BUG=5806
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/search_provider.cc')
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 17bdcc8..cd25d13 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -10,6 +10,7 @@ #include "chrome/browser/google_util.h" #include "chrome/browser/profile.h" #include "chrome/browser/template_url_model.h" +#include "chrome/browser/url_fixer_upper.h" #include "chrome/common/json_value_serializer.h" #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" @@ -317,12 +318,17 @@ bool SearchProvider::ParseSuggestResults(Value* root_val) { type_val->GetAsString(&type_str) && (type_str == L"NAVIGATION")) { Value* site_val; std::wstring site_name; - if (navigation_results_.size() < max_matches() && + if ((navigation_results_.size() < max_matches()) && description_list && description_list->Get(i, &site_val) && site_val->IsType(Value::TYPE_STRING) && site_val->GetAsString(&site_name)) { - navigation_results_.push_back(NavigationResult(GURL(suggestion_str), - site_name)); + // We can't blindly trust the URL coming from the server to be valid. + GURL result_url = + GURL(URLFixerUpper::FixupURL(suggestion_str, std::wstring())); + if (result_url.is_valid()) { + navigation_results_.push_back(NavigationResult(result_url, + site_name)); + } } } else { // TODO(kochi): Currently we treat a calculator result as a query, but it |