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
1 changed files with 5 additions and 3 deletions

View File

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