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

Unified Diff: components/omnibox/browser/autocomplete_input.cc

Issue 2378213002: Mark URLs with empty schemes as invalid. (Closed)
Patch Set: . Created 4 years, 3 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
« no previous file with comments | « no previous file | components/url_formatter/url_fixer.cc » ('j') | components/url_formatter/url_fixer.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/omnibox/browser/autocomplete_input.cc
diff --git a/components/omnibox/browser/autocomplete_input.cc b/components/omnibox/browser/autocomplete_input.cc
index 7207fc8b5e68ba44e4e354bbc79b4f3317e4d5d1..73e8844c351e8d2faf08c0335cf367561f913183 100644
--- a/components/omnibox/browser/autocomplete_input.cc
+++ b/components/omnibox/browser/autocomplete_input.cc
@@ -155,6 +155,12 @@ metrics::OmniboxInputType::Type AutocompleteInput::Parse(
if (first_non_white == base::string16::npos)
return metrics::OmniboxInputType::INVALID; // All whitespace.
+ // Treat input that begins with a colon as a query. Otherwise the URL
+ // formatter will attempt to fix it by prepending a scheme, which the user
+ // probably did not want if they explicitly typed a colon at the beginning.
+ if (text[first_non_white] == ':')
+ return metrics::OmniboxInputType::QUERY;
Peter Kasting 2016/10/05 00:56:30 I'm fine with doing what you did to the URLFixerUp
brettw 2016/10/05 05:10:12 It does return UNKNOWN at the bottom, and I was tr
+
// Ask our parsing back-end to help us understand what the user typed. We
// use the URLFixerUpper here because we want to be smart about what we
// consider a scheme. For example, we shouldn't consider www.google.com:80
@@ -254,13 +260,6 @@ metrics::OmniboxInputType::Type AutocompleteInput::Parse(
// between an HTTP URL and a query, or the scheme is HTTP or HTTPS, in which
// case we should reject invalid formulations.
- // If we have an empty host it can't be a valid HTTP[S] URL. (This should
- // only trigger for input that begins with a colon, which GURL will parse as a
- // valid, non-standard URL; for standard URLs, an empty host would have
- // resulted in an invalid |canonicalized_url| above.)
- if (!canonicalized_url->has_host())
- return metrics::OmniboxInputType::QUERY;
-
// Determine the host family. We get this information by (re-)canonicalizing
// the already-canonicalized host rather than using the user's original input,
// in case fixup affected the result here (e.g. an input that looks like an
« no previous file with comments | « no previous file | components/url_formatter/url_fixer.cc » ('j') | components/url_formatter/url_fixer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698