Commit f0953ccb authored by pkasting@chromium.org's avatar pkasting@chromium.org

Force navigation to non-numeric hostnames with ports (e.g. "abc:81"). This...

Force navigation to non-numeric hostnames with ports (e.g. "abc:81").  This restores the pre-Chrome-15 behavior for these inputs.

BUG=103598
TEST=Typing "abcdefg:123" in the address bar should attempt to navigate, not search, by default.
Review URL: http://codereview.chromium.org/8510024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110821 0039d316-1c4b-4281-b951-d872f2087c98
parent a2d2e2f9
......@@ -371,8 +371,8 @@ AutocompleteInput::Type AutocompleteInput::Parse(
if (NumNonHostComponents(*parts) > 1)
return URL;
// If the host has a known TLD, it's probably a URL, with the following
// exceptions:
// If the host has a known TLD or a port, it's probably a URL, with the
// following exceptions:
// * Any "IP addresses" that make it here are more likely searches
// (see above).
// * If we reach here with a username, our input looks like "user@host[.tld]".
......@@ -381,7 +381,8 @@ AutocompleteInput::Type AutocompleteInput::Parse(
// default and let users correct us on a case-by-case basis.
// Note that we special-case "localhost" as a known hostname.
if ((host_info.family != url_canon::CanonHostInfo::IPV4) &&
((registry_length != 0) || (host == ASCIIToUTF16("localhost"))))
((registry_length != 0) || (host == ASCIIToUTF16("localhost") ||
parts->port.is_nonempty())))
return parts->username.is_nonempty() ? UNKNOWN : URL;
// If we reach this point, we know there's no known TLD on the input, so if
......
......@@ -304,7 +304,7 @@ TEST_F(AutocompleteTest, InputType) {
{ ASCIIToUTF16("foo+bar.com"), AutocompleteInput::UNKNOWN },
{ ASCIIToUTF16("\"foo:bar\""), AutocompleteInput::QUERY },
{ ASCIIToUTF16("link:foo.com"), AutocompleteInput::UNKNOWN },
{ ASCIIToUTF16("foo:81"), AutocompleteInput::UNKNOWN },
{ ASCIIToUTF16("foo:81"), AutocompleteInput::URL },
{ ASCIIToUTF16("localhost:8080"), AutocompleteInput::URL },
{ ASCIIToUTF16("www.foo.com:81"), AutocompleteInput::URL },
{ ASCIIToUTF16("foo.com:123456"), AutocompleteInput::QUERY },
......@@ -331,15 +331,13 @@ TEST_F(AutocompleteTest, InputType) {
{ ASCIIToUTF16("host#ref"), AutocompleteInput::UNKNOWN },
{ ASCIIToUTF16("host/path?query"), AutocompleteInput::URL },
{ ASCIIToUTF16("host/path#ref"), AutocompleteInput::URL },
{ ASCIIToUTF16("en.wikipedia.org/wiki/James Bond"),
AutocompleteInput::URL },
{ ASCIIToUTF16("en.wikipedia.org/wiki/Jim Beam"), AutocompleteInput::URL },
// In Chrome itself, mailto: will get handled by ShellExecute, but in
// unittest mode, we don't have the data loaded in the external protocol
// handler to know this.
// { ASCIIToUTF16("mailto:abuse@foo.com"), AutocompleteInput::URL },
{ ASCIIToUTF16("view-source:http://www.foo.com/"), AutocompleteInput::URL },
{ ASCIIToUTF16("javascript:alert(\"Hey there!\");"),
AutocompleteInput::URL },
{ ASCIIToUTF16("javascript:alert(\"Hi there\");"), AutocompleteInput::URL },
#if defined(OS_WIN)
{ ASCIIToUTF16("C:\\Program Files"), AutocompleteInput::URL },
{ ASCIIToUTF16("\\\\Server\\Folder\\File"), AutocompleteInput::URL },
......@@ -370,12 +368,10 @@ TEST_F(AutocompleteTest, InputType) {
{ ASCIIToUTF16("127.0.1/"), AutocompleteInput::URL },
{ ASCIIToUTF16("browser.tabs.closeButtons"), AutocompleteInput::UNKNOWN },
{ WideToUTF16(L"\u6d4b\u8bd5"), AutocompleteInput::UNKNOWN },
{ ASCIIToUTF16("[2001:]"), AutocompleteInput::QUERY }, // Not a valid IP
{ ASCIIToUTF16("[2001:]"), AutocompleteInput::QUERY },
{ ASCIIToUTF16("[2001:dB8::1]"), AutocompleteInput::URL },
{ ASCIIToUTF16("192.168.0.256"),
AutocompleteInput::QUERY }, // Invalid IPv4 literal.
{ ASCIIToUTF16("[foo.com]"),
AutocompleteInput::QUERY }, // Invalid IPv6 literal.
{ ASCIIToUTF16("192.168.0.256"), AutocompleteInput::QUERY },
{ ASCIIToUTF16("[foo.com]"), AutocompleteInput::QUERY },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment