summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2018-02-11 20:25:02 +0100
committerLauris BH <lauris@nix.lv>2018-02-11 21:25:02 +0200
commitc0675ef6c29933376bd77b056f55d8e2a788602f (patch)
treec003e80673db5ca1b283d701d0760a2fa1b74eb8 /modules
parent4e27cc48132c1d59259d2045309a1a3ae7c35f59 (diff)
downloadgitea-c0675ef6c29933376bd77b056f55d8e2a788602f.tar.gz
gitea-c0675ef6c29933376bd77b056f55d8e2a788602f.zip
Escape search query (Backport 1.4) (#3488)
* Escape search query Signed-off-by: Jonas Franz <info@jonasfranz.de> (cherry picked from commit 2970889) * Reordered imports Signed-off-by: Jonas Franz <info@jonasfranz.de>
Diffstat (limited to 'modules')
-rw-r--r--modules/templates/helper.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index d6be25cebb..2eac62901f 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -10,6 +10,7 @@ import (
"encoding/json"
"errors"
"fmt"
+ "html"
"html/template"
"mime"
"net/url"
@@ -179,6 +180,7 @@ func NewFuncMap() []template.FuncMap {
return dict, nil
},
"Printf": fmt.Sprintf,
+ "Escape": Escape,
}}
}
@@ -197,6 +199,11 @@ func Str2html(raw string) template.HTML {
return template.HTML(markup.Sanitize(raw))
}
+// Escape escapes a HTML string
+func Escape(raw string) string {
+ return html.EscapeString(raw)
+}
+
// List traversings the list
func List(l *list.List) chan interface{} {
e := l.Front()