aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/httputil/reverseproxy.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-11-14 12:02:23 -0800
committerGopher Robot <gobot@golang.org>2022-11-15 00:02:58 +0000
commite6ebbefaf848604c8df3e2a58e146948b03e608b (patch)
tree49c7cc356b4d83e9c86a336e6f9f58a099bd3242 /src/net/http/httputil/reverseproxy.go
parent2b59307ac21135ab8db58e08fb98211fbedbb10d (diff)
downloadgo-e6ebbefaf848604c8df3e2a58e146948b03e608b.tar.xz
net/url, net/http/httputil: accept invalid percent encodings
Per https://url.spec.whatwg.org/#percent-encoded-bytes an invalid percent encoding should be handled as ordinary text. Fixes #56732 Change-Id: Ib0259dfd704922905289eebaacbf722e28f6d636 Reviewed-on: https://go-review.googlesource.com/c/go/+/450375 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/net/http/httputil/reverseproxy.go')
-rw-r--r--src/net/http/httputil/reverseproxy.go27
1 files changed, 1 insertions, 26 deletions
diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go
index 190279ca00..ad0221ff33 100644
--- a/src/net/http/httputil/reverseproxy.go
+++ b/src/net/http/httputil/reverseproxy.go
@@ -816,34 +816,9 @@ func (c switchProtocolCopier) copyToBackend(errc chan<- error) {
}
func cleanQueryParams(s string) string {
- reencode := func(s string) string {
+ if strings.Contains(s, ";") {
v, _ := url.ParseQuery(s)
return v.Encode()
}
- for i := 0; i < len(s); {
- switch s[i] {
- case ';':
- return reencode(s)
- case '%':
- if i+2 >= len(s) || !ishex(s[i+1]) || !ishex(s[i+2]) {
- return reencode(s)
- }
- i += 3
- default:
- i++
- }
- }
return s
}
-
-func ishex(c byte) bool {
- switch {
- case '0' <= c && c <= '9':
- return true
- case 'a' <= c && c <= 'f':
- return true
- case 'A' <= c && c <= 'F':
- return true
- }
- return false
-}