summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc6
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc4
2 files changed, 9 insertions, 1 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index 4b9db4e..65f71c4 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -181,8 +181,12 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// See if the host is an IP address.
bool is_ip_address;
- net::CanonicalizeHost(host, &is_ip_address);
+ const std::string canon_host(net::CanonicalizeHost(host, &is_ip_address));
if (is_ip_address) {
+ // If the user typed a valid IPv6 address, treat it as a URL.
+ if (canon_host[0] == '[')
+ return URL;
+
// If the user originally typed a host that looks like an IP address (a
// dotted quad), they probably want to open it. If the original input was
// something else (like a single number), they probably wanted to search for
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index 6cdd646..e7fdd4c 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -233,8 +233,12 @@ TEST(AutocompleteTest, InputType) {
#endif // defined(OS_WIN)
{ L"http://foo.com/", AutocompleteInput::URL },
{ L"127.0.0.1", AutocompleteInput::URL },
+ { L"127.0.1", AutocompleteInput::UNKNOWN },
+ { L"127.0.1/", AutocompleteInput::UNKNOWN },
{ L"browser.tabs.closeButtons", AutocompleteInput::UNKNOWN },
{ L"\u6d4b\u8bd5", AutocompleteInput::UNKNOWN },
+ { L"[2001:]", AutocompleteInput::QUERY }, // Not a valid IP
+ { L"[2001:dB8::1]", AutocompleteInput::URL },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) {