New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 736324 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

GetHostNameWithHTTPScheme mangles literal IPv6 addresses, has confusing comments

Project Member Reported by ricea@chromium.org, Jun 23 2017

Issue description

In password_protection_service.cc GetHostNameWithHTTPScheme() uses url.HostNoBrackets() to get the hostname. So for a URL containing an IPv6 address like https://[::1]/foo it will retrieve a hostname of "::1", then concatenate it with http:// to produce http://::1 which is an invalid URL.

I couldn't see any tests for IPv6 literal addresses so I can't tell whether or not this has an impact on the correctness of the function. It seems unlikely that creating invalid URLs is the intent of the function, but if it is it would be helpful to readers if it was mentioned in a comment.

It should probably be using url.host() rather than HostNoBrackets(). Or host_piece() for less string copies.

The comment on the function says
// Given a URL of either http or https scheme, return its scheme://hostname.
// e.g., "https://www.foo.com:80/bar/test.cgi" -> "http://www.foo.com".

I think instead of "its scheme://hostname" this should say "http://hostname".
 

Comment 1 by ricea@chromium.org, Jun 23 2017

While I am nitpicking, could you change

const std::string& hostname = url.HostNoBrackets();

in PasswordProtectionService::CanGetReputationOfURL() to not be a reference? Although it works here, taking a reference to a temporary is confusing and may have surprising consequences later.
Status: Started (was: Assigned)
Status: Fixed (was: Started)

Sign in to add a comment