Commit ab4e009f authored by jialiul's avatar jialiul Committed by Commit Bot

Fix GetHostNameWithHTTPScheme for IPv6 addresses

BUG=736324

Review-Url: https://codereview.chromium.org/2959443003
Cr-Commit-Position: refs/heads/master@{#481905}
parent aefd605c
......@@ -62,12 +62,12 @@ size_t GetPathDepth(const std::string& cache_expression_path) {
.size();
}
// Given a URL of either http or https scheme, return its scheme://hostname.
// Given a URL of either http or https scheme, return its http://hostname.
// e.g., "https://www.foo.com:80/bar/test.cgi" -> "http://www.foo.com".
GURL GetHostNameWithHTTPScheme(const GURL& url) {
DCHECK(url.SchemeIsHTTPOrHTTPS());
std::string result(url::kHttpScheme);
result.append(url::kStandardSchemeSeparator).append(url.HostNoBrackets());
result.append(url::kStandardSchemeSeparator).append(url.host());
return GURL(result);
}
......@@ -115,7 +115,7 @@ bool PasswordProtectionService::CanGetReputationOfURL(const GURL& url) {
if (!url.is_valid() || !url.SchemeIsHTTPOrHTTPS())
return false;
const std::string& hostname = url.HostNoBrackets();
const std::string hostname = url.HostNoBrackets();
return !net::IsLocalhost(hostname) && !net::IsHostnameNonUnique(hostname) &&
hostname.find('.') != std::string::npos;
}
......
......@@ -539,7 +539,7 @@ TEST_F(PasswordProtectionServiceTest, VerifyCanGetReputationOfURL) {
EXPECT_FALSE(PasswordProtectionService::CanGetReputationOfURL(
GURL("http://10.0.1.0/")));
EXPECT_FALSE(PasswordProtectionService::CanGetReputationOfURL(
GURL("http://FEED::BEEF")));
GURL("http://[FEED::BEEF]")));
// Main frame URL is a no-yet-assigned y ICANN gTLD.
EXPECT_FALSE(PasswordProtectionService::CanGetReputationOfURL(
......
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