]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "net/url: validate ports in IPv4 addresses"
authorRuss Cox <rsc@golang.org>
Fri, 6 May 2016 15:34:25 +0000 (15:34 +0000)
committerRuss Cox <rsc@golang.org>
Fri, 6 May 2016 18:53:01 +0000 (18:53 +0000)
This reverts commit 9f1ccd647fcdb1b703c1042c90434e15aff75013.

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>

src/net/url/url.go
src/net/url/url_test.go

index 05b41fa964a9ccde6ab7d88eeb3512f91f5f34c4..d9c8c49e94a48393047f3dfa94070b65ebc66f2a 100644 (file)
@@ -573,12 +573,8 @@ func parseHost(host string) (string, error) {
                        }
                        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
        if host, err = unescape(host, encodeHost); err != nil {
                return "", err
index da6bc2843e52b06249ba3c87e4468655bd5e079c..7560f22c4a1e2a7f258b7d4f2f256a6e02859938 100644 (file)
@@ -418,10 +418,10 @@ var urltests = []URLTest{
        },
        // worst case host, still round trips
        {
-               "scheme://!$&'()*+,;=hello!:8080/path",
+               "scheme://!$&'()*+,;=hello!:port/path",
                &URL{
                        Scheme: "scheme",
-                       Host:   "!$&'()*+,;=hello!:8080",
+                       Host:   "!$&'()*+,;=hello!:port",
                        Path:   "/path",
                },
                "",
@@ -636,10 +636,8 @@ var parseRequestURLTests = []struct {
        {"*", true},
        {"http://192.168.0.1/", true},
        {"http://192.168.0.1:8080/", true},
-       {"http://192.168.0.1:foo/", false},
        {"http://[fe80::1]/", true},
        {"http://[fe80::1]:8080/", true},
-       {"http://[fe80::1]:foo/", false},
 
        // Tests exercising RFC 6874 compliance:
        {"http://[fe80::1%25en0]/", true},                 // with alphanum zone identifier