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

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..b3b761b5cb6e37b0aff7ffcb3b6e1c067e5a2b46 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 beings with a colon as a query. Otherwise the URL
Peter Kasting 2016/09/29 04:54:12 Nit: begins
+ // 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/09/29 04:54:12 It would be nice to avoid doing this check here, a
+
// 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