aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/http/server.go')
-rw-r--r--src/pkg/http/server.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go
index 8326ff8be1..e8e23087e0 100644
--- a/src/pkg/http/server.go
+++ b/src/pkg/http/server.go
@@ -752,13 +752,16 @@ func Redirect(w ResponseWriter, r *Request, urlStr string, code int) {
}
}
+var htmlReplacer = strings.NewReplacer(
+ "&", "&",
+ "<", "&lt;",
+ ">", "&gt;",
+ `"`, "&quot;",
+ "'", "&apos;",
+)
+
func htmlEscape(s string) string {
- s = strings.Replace(s, "&", "&amp;", -1)
- s = strings.Replace(s, "<", "&lt;", -1)
- s = strings.Replace(s, ">", "&gt;", -1)
- s = strings.Replace(s, "\"", "&quot;", -1)
- s = strings.Replace(s, "'", "&apos;", -1)
- return s
+ return htmlReplacer.Replace(s)
}
// Redirect to a fixed URL