Skip to content

Commit f0e2d32

Browse files
committed
Revert "net/url: validate ports in IPv4 addresses"
This reverts commit 9f1ccd6. For #14860. Change-Id: I63522a4dda8915dc8b972ae2e12495553ed65f09 Reviewed-on: https://go-review.googlesource.com/22861 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 4eccc77 commit f0e2d32

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/net/url/url.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,8 @@ func parseHost(host string) (string, error) {
573573
}
574574
return host1 + host2 + host3, nil
575575
}
576-
} else if i := strings.LastIndex(host, ":"); i > 0 {
577-
colonPort := host[i:]
578-
if !validOptionalPort(colonPort) {
579-
return "", fmt.Errorf("invalid port %q after host", colonPort)
580-
}
581576
}
577+
582578
var err error
583579
if host, err = unescape(host, encodeHost); err != nil {
584580
return "", err

src/net/url/url_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,10 @@ var urltests = []URLTest{
418418
},
419419
// worst case host, still round trips
420420
{
421-
"scheme://!$&'()*+,;=hello!:8080/path",
421+
"scheme://!$&'()*+,;=hello!:port/path",
422422
&URL{
423423
Scheme: "scheme",
424-
Host: "!$&'()*+,;=hello!:8080",
424+
Host: "!$&'()*+,;=hello!:port",
425425
Path: "/path",
426426
},
427427
"",
@@ -636,10 +636,8 @@ var parseRequestURLTests = []struct {
636636
{"*", true},
637637
{"http://192.168.0.1/", true},
638638
{"http://192.168.0.1:8080/", true},
639-
{"http://192.168.0.1:foo/", false},
640639
{"http://[fe80::1]/", true},
641640
{"http://[fe80::1]:8080/", true},
642-
{"http://[fe80::1]:foo/", false},
643641

644642
// Tests exercising RFC 6874 compliance:
645643
{"http://[fe80::1%25en0]/", true}, // with alphanum zone identifier

0 commit comments

Comments
 (0)