mirror of
https://github.com/golang/go
synced 2024-09-25 05:20:13 -06:00
Revert "net/url: validate ports in IPv4 addresses"
This reverts commit 9f1ccd647f
.
For #14860.
Change-Id: I63522a4dda8915dc8b972ae2e12495553ed65f09
Reviewed-on: https://go-review.googlesource.com/22861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
4eccc77f19
commit
f0e2d32fde
@ -573,12 +573,8 @@ func parseHost(host string) (string, error) {
|
|||||||
}
|
}
|
||||||
return host1 + host2 + host3, nil
|
return host1 + host2 + host3, nil
|
||||||
}
|
}
|
||||||
} else if i := strings.LastIndex(host, ":"); i > 0 {
|
|
||||||
colonPort := host[i:]
|
|
||||||
if !validOptionalPort(colonPort) {
|
|
||||||
return "", fmt.Errorf("invalid port %q after host", colonPort)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if host, err = unescape(host, encodeHost); err != nil {
|
if host, err = unescape(host, encodeHost); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -418,10 +418,10 @@ var urltests = []URLTest{
|
|||||||
},
|
},
|
||||||
// worst case host, still round trips
|
// worst case host, still round trips
|
||||||
{
|
{
|
||||||
"scheme://!$&'()*+,;=hello!:8080/path",
|
"scheme://!$&'()*+,;=hello!:port/path",
|
||||||
&URL{
|
&URL{
|
||||||
Scheme: "scheme",
|
Scheme: "scheme",
|
||||||
Host: "!$&'()*+,;=hello!:8080",
|
Host: "!$&'()*+,;=hello!:port",
|
||||||
Path: "/path",
|
Path: "/path",
|
||||||
},
|
},
|
||||||
"",
|
"",
|
||||||
@ -636,10 +636,8 @@ var parseRequestURLTests = []struct {
|
|||||||
{"*", true},
|
{"*", true},
|
||||||
{"http://192.168.0.1/", true},
|
{"http://192.168.0.1/", true},
|
||||||
{"http://192.168.0.1:8080/", true},
|
{"http://192.168.0.1:8080/", true},
|
||||||
{"http://192.168.0.1:foo/", false},
|
|
||||||
{"http://[fe80::1]/", true},
|
{"http://[fe80::1]/", true},
|
||||||
{"http://[fe80::1]:8080/", true},
|
{"http://[fe80::1]:8080/", true},
|
||||||
{"http://[fe80::1]:foo/", false},
|
|
||||||
|
|
||||||
// Tests exercising RFC 6874 compliance:
|
// Tests exercising RFC 6874 compliance:
|
||||||
{"http://[fe80::1%25en0]/", true}, // with alphanum zone identifier
|
{"http://[fe80::1%25en0]/", true}, // with alphanum zone identifier
|
||||||
|
Loading…
Reference in New Issue
Block a user