mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Revert "net/url: disallow raw IPv6 addresses in host"
This reverts commit e3be2d1b2b.
Reason for revert: Causes extensive failures in Google-internal testing.
Change-Id: I232f547fc326dff7df959d25f3a89777ea33b201
Reviewed-on: https://go-review.googlesource.com/c/go/+/711800
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
5a9ef44bc0
commit
0a239bcc99
2 changed files with 21 additions and 6 deletions
|
|
@ -698,9 +698,7 @@ func parseHost(host string) (string, error) {
|
||||||
return "", errors.New("invalid IP-literal")
|
return "", errors.New("invalid IP-literal")
|
||||||
}
|
}
|
||||||
return "[" + unescapedHostname + "]" + unescapedColonPort, nil
|
return "[" + unescapedHostname + "]" + unescapedColonPort, nil
|
||||||
} else if i := strings.Index(host, ":"); i != -1 {
|
} else if i := strings.LastIndex(host, ":"); i != -1 {
|
||||||
// IPv4address / reg-name
|
|
||||||
// E.g. 1.2.3.4, 1.2.3.4:80, example.com, example.com:80
|
|
||||||
colonPort := host[i:]
|
colonPort := host[i:]
|
||||||
if !validOptionalPort(colonPort) {
|
if !validOptionalPort(colonPort) {
|
||||||
return "", fmt.Errorf("invalid port %q after host", colonPort)
|
return "", fmt.Errorf("invalid port %q after host", colonPort)
|
||||||
|
|
|
||||||
|
|
@ -506,6 +506,26 @@ var urltests = []URLTest{
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Malformed IPv6 but still accepted.
|
||||||
|
"http://2b01:e34:ef40:7730:8e70:5aff:fefe:edac:8080/foo",
|
||||||
|
&URL{
|
||||||
|
Scheme: "http",
|
||||||
|
Host: "2b01:e34:ef40:7730:8e70:5aff:fefe:edac:8080",
|
||||||
|
Path: "/foo",
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Malformed IPv6 but still accepted.
|
||||||
|
"http://2b01:e34:ef40:7730:8e70:5aff:fefe:edac:/foo",
|
||||||
|
&URL{
|
||||||
|
Scheme: "http",
|
||||||
|
Host: "2b01:e34:ef40:7730:8e70:5aff:fefe:edac:",
|
||||||
|
Path: "/foo",
|
||||||
|
},
|
||||||
|
"",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"http://[2b01:e34:ef40:7730:8e70:5aff:fefe:edac]:8080/foo",
|
"http://[2b01:e34:ef40:7730:8e70:5aff:fefe:edac]:8080/foo",
|
||||||
&URL{
|
&URL{
|
||||||
|
|
@ -715,9 +735,6 @@ var parseRequestURLTests = []struct {
|
||||||
{"https://[0:0::test.com]:80", false},
|
{"https://[0:0::test.com]:80", false},
|
||||||
{"https://[2001:db8::test.com]", false},
|
{"https://[2001:db8::test.com]", false},
|
||||||
{"https://[test.com]", false},
|
{"https://[test.com]", false},
|
||||||
{"https://1:2:3:4:5:6:7:8", false},
|
|
||||||
{"https://1:2:3:4:5:6:7:8:80", false},
|
|
||||||
{"https://example.com:80:", false},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseRequestURI(t *testing.T) {
|
func TestParseRequestURI(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue