diff options
Diffstat (limited to 'src/net/url/url.go')
| -rw-r--r-- | src/net/url/url.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/net/url/url.go b/src/net/url/url.go index 202957a3a2..36d1820084 100644 --- a/src/net/url/url.go +++ b/src/net/url/url.go @@ -547,7 +547,9 @@ func parseAuthority(scheme, authority string) (user *Userinfo, host string, err // parseHost parses host as an authority without user // information. That is, as host[:port]. func parseHost(scheme, host string) (string, error) { - if openBracketIdx := strings.LastIndex(host, "["); openBracketIdx != -1 { + if openBracketIdx := strings.LastIndex(host, "["); openBracketIdx > 0 { + return "", errors.New("invalid IP-literal") + } else if openBracketIdx == 0 { // Parse an IP-Literal in RFC 3986 and RFC 6874. // E.g., "[fe80::1]", "[fe80::1%25en0]", "[fe80::1]:80". closeBracketIdx := strings.LastIndex(host, "]") |
