Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1320)

Unified Diff: chrome/browser/autocomplete/history_provider.cc

Issue 7822009: Fix crash in CanFindIntranetURL() due to FixupUserInput() changing the AutocompleteInput's text_ ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/history_provider.cc
===================================================================
--- chrome/browser/autocomplete/history_provider.cc (revision 98899)
+++ chrome/browser/autocomplete/history_provider.cc (working copy)
@@ -60,15 +60,18 @@
}
// static
-string16 HistoryProvider::FixupUserInput(const AutocompleteInput& input) {
- const string16& input_text = input.text();
+bool HistoryProvider::FixupUserInput(AutocompleteInput* input) {
+ const string16& input_text = input->text();
// Fixup and canonicalize user input.
+ // NOTE: This purposefully doesn't take input.desired_tld() into account; if
+ // it did, then holding "ctrl" would change all the results from the provider,
+ // not just the What You Typed Result.
const GURL canonical_gurl(URLFixerUpper::FixupURL(UTF16ToUTF8(input_text),
std::string()));
std::string canonical_gurl_str(canonical_gurl.possibly_invalid_spec());
if (canonical_gurl_str.empty()) {
// This probably won't happen, but there are no guarantees.
- return input_text;
+ return false;
}
// If the user types a number, GURL will convert it to a dotted quad.
@@ -77,11 +80,11 @@
// for hostname beginning with numbers (e.g. input of "17173" will be matched
// against "0.0.67.21" instead of the original "17173", failing to find
// "17173.com"), swap the original hostname in for the fixed-up one.
- if ((input.type() != AutocompleteInput::URL) &&
+ if ((input->type() != AutocompleteInput::URL) &&
canonical_gurl.HostIsIPAddress()) {
std::string original_hostname =
- UTF16ToUTF8(input_text.substr(input.parts().host.begin,
- input.parts().host.len));
+ UTF16ToUTF8(input_text.substr(input->parts().host.begin,
+ input->parts().host.len));
const url_parse::Parsed& parts =
canonical_gurl.parsed_for_possibly_invalid_spec();
// parts.host must not be empty when HostIsIPAddress() is true.
@@ -125,7 +128,10 @@
else if (num_output_slashes > num_input_slashes)
output.erase(output.length() - num_output_slashes + num_input_slashes);
- return output;
+ url_parse::Parsed parts;
+ URLFixerUpper::SegmentURL(output, &parts);
+ input->UpdateText(output, parts);
+ return !output.empty();
}
// static
« no previous file with comments | « chrome/browser/autocomplete/history_provider.h ('k') | chrome/browser/autocomplete/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698