aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/http/http.go')
-rw-r--r--src/net/http/http.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/net/http/http.go b/src/net/http/http.go
index 101799f574..9b81654fcc 100644
--- a/src/net/http/http.go
+++ b/src/net/http/http.go
@@ -86,14 +86,20 @@ func hexEscapeNonASCII(s string) string {
return s
}
b := make([]byte, 0, newLen)
+ var pos int
for i := 0; i < len(s); i++ {
if s[i] >= utf8.RuneSelf {
+ if pos < i {
+ b = append(b, s[pos:i]...)
+ }
b = append(b, '%')
b = strconv.AppendInt(b, int64(s[i]), 16)
- } else {
- b = append(b, s[i])
+ pos = i + 1
}
}
+ if pos < len(s) {
+ b = append(b, s[pos:]...)
+ }
return string(b)
}