diff options
author | Marcel van Lohuizen <mpvl@golang.org> | 2017-02-16 16:14:16 +0100 |
---|---|---|
committer | Marcel van Lohuizen <mpvl@golang.org> | 2017-03-24 13:30:17 +0000 |
commit | 48de5a85fbc452bfc3af7422cd8aba0fab132d3d (patch) | |
tree | 87d0fe248a66ec740871cf38e9eee2afe5d496eb /src/net/http/request.go | |
parent | 3e63cdf8507709ebfb0906a3dbdc14c402cc0cd6 (diff) | |
download | go-git-48de5a85fbc452bfc3af7422cd8aba0fab132d3d.tar.gz |
net/http: import updated idna package and adjust request.go
Custom logic from request.go has been removed.
Created by running: “go run gen.go -core” from x/text
at fc7fa097411d30e6708badff276c4c164425590c.
Fixes golang/go#17268
Change-Id: Ie440d6ae30288352283d303e5126e5837f11bece
Reviewed-on: https://go-review.googlesource.com/37111
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/http/request.go')
-rw-r--r-- | src/net/http/request.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/net/http/request.go b/src/net/http/request.go index 09d998dacf..a6e96259a0 100644 --- a/src/net/http/request.go +++ b/src/net/http/request.go @@ -27,8 +27,6 @@ import ( "sync" "golang_org/x/net/idna" - "golang_org/x/text/unicode/norm" - "golang_org/x/text/width" ) const ( @@ -639,16 +637,19 @@ func (req *Request) write(w io.Writer, usingProxy bool, extraHeaders Header, wai type requestBodyReadError struct{ error } func idnaASCII(v string) (string, error) { + // TODO: Consider removing this check after verifying performance is okay. + // Right now punycode verification, length checks, context checks, and the + // permissable character tests are all omitted. It also prevents the ToASCII + // call from salvaging an invalid IDN, when possible. As a result it may be + // possible to have two IDNs that appear identical to the user where the + // ASCII-only version causes an error downstream whereas the non-ASCII + // version does not. + // Note that for correct ASCII IDNs ToASCII will only do considerably more + // work, but it will not cause an allocation. if isASCII(v) { return v, nil } - // The idna package doesn't do everything from - // https://tools.ietf.org/html/rfc5895 so we do it here. - // TODO(bradfitz): should the idna package do this instead? - v = strings.ToLower(v) - v = width.Fold.String(v) - v = norm.NFC.String(v) - return idna.ToASCII(v) + return idna.Lookup.ToASCII(v) } // cleanHost cleans up the host sent in request's Host header. |