aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/http')
-rw-r--r--src/net/http/http.go13
-rw-r--r--src/net/http/request.go2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/net/http/http.go b/src/net/http/http.go
index 5c03c16c87..e5d59e1412 100644
--- a/src/net/http/http.go
+++ b/src/net/http/http.go
@@ -59,10 +59,15 @@ func isASCII(s string) bool {
return true
}
-// isCTL reports whether r is an ASCII control character, including
-// the Extended ASCII control characters included in Unicode.
-func isCTL(r rune) bool {
- return r < ' ' || 0x7f <= r && r <= 0x9f
+// stringContainsCTLByte reports whether s contains any ASCII control character.
+func stringContainsCTLByte(s string) bool {
+ for i := 0; i < len(s); i++ {
+ b := s[i]
+ if b < ' ' || b == 0x7f {
+ return true
+ }
+ }
+ return false
}
func hexEscapeNonASCII(s string) string {
diff --git a/src/net/http/request.go b/src/net/http/request.go
index 01ba1dc1fb..dcad2b6fab 100644
--- a/src/net/http/request.go
+++ b/src/net/http/request.go
@@ -550,7 +550,7 @@ func (r *Request) write(w io.Writer, usingProxy bool, extraHeaders Header, waitF
ruri = r.URL.Opaque
}
}
- if strings.IndexFunc(ruri, isCTL) != -1 {
+ if stringContainsCTLByte(ruri) {
return errors.New("net/http: can't write control character in Request.URL")
}
// TODO: validate r.Method too? At least it's less likely to