fix xss on error page

This commit is contained in:
crapStone 2022-12-02 13:42:03 +01:00
parent 5e72753e91
commit a3e54c91cf
No known key found for this signature in database
GPG Key ID: 4CAA9E39EEDEB1F0

View File

@ -1,6 +1,7 @@
package html package html
import ( import (
"html/template"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
@ -39,7 +40,8 @@ func errorMessage(statusCode int) string {
// TODO: use template engine // TODO: use template engine
func errorBody(statusCode int) string { func errorBody(statusCode int) string {
return strings.ReplaceAll(NotFoundPage, return template.HTMLEscapeString(
"%status%", strings.ReplaceAll(NotFoundPage,
strconv.Itoa(statusCode)+" "+errorMessage(statusCode)) "%status%",
strconv.Itoa(statusCode)+" "+errorMessage(statusCode)))
} }