Commit 0416d890 authored by Mustafa Emre Acer's avatar Mustafa Emre Acer Committed by Chromium LUCI CQ

Default typed omnibox navigations to https: Exclude certain hostnames

This CL excludes disables HTTPS upgrades for IP addresses and adds tests
for non-unique hostnames.

Bug: 1141691
Change-Id: Ib697d254abb32c375e0eda40b0f22fe521175f02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616978
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarChris Thompson <cthomp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842152}
parent bb5d7df6
......@@ -153,7 +153,9 @@ void AutocompleteInput::Init(
if (should_use_https_as_default_scheme_ &&
type_ == metrics::OmniboxInputType::URL &&
scheme_ == base::ASCIIToUTF16(url::kHttpScheme) &&
!base::StartsWith(text_, scheme_, base::CompareCase::INSENSITIVE_ASCII)) {
!base::StartsWith(text_, scheme_, base::CompareCase::INSENSITIVE_ASCII) &&
!url::HostIsIPAddress(base::UTF16ToUTF8(text)) &&
!net::IsHostnameNonUnique(base::UTF16ToUTF8(text))) {
// Use HTTPS as the default scheme for URLs that are typed without a scheme.
// Inputs of type UNKNOWN can still be valid URLs, but these will be mainly
// intranet hosts which we don't to upgrade to HTTPS so we only check the
......
......@@ -384,6 +384,10 @@ TEST(AutocompleteInputTest, UpgradeTypedNavigationsToHttps) {
{ASCIIToUTF16("example.com"), GURL("https://example.com"), true},
// Non-URL inputs shouldn't be upgraded.
{ASCIIToUTF16("example query"), GURL(), false},
// IP addresses shouldn't be upgraded.
{ASCIIToUTF16("127.0.0.1"), GURL("http://127.0.0.1"), false},
// Non-unique hostnames shouldn't be upgraded.
{ASCIIToUTF16("site.test"), GURL("http://site.test"), false},
// Fully typed URLs shouldn't be upgraded.
{ASCIIToUTF16("http://example.com"), GURL("http://example.com"), false},
{ASCIIToUTF16("HTTP://EXAMPLE.COM"), GURL("http://example.com"), false},
......
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