Escape search query (Backport 1.3) (#3489)
* 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>
This commit is contained in:
parent
88c363f933
commit
ed27da4b0a
|
@ -9,6 +9,7 @@ import (
|
||||||
"container/list"
|
"container/list"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"html/template"
|
"html/template"
|
||||||
"mime"
|
"mime"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -162,6 +163,7 @@ func NewFuncMap() []template.FuncMap {
|
||||||
"UnescapeLocale": func(str string) string {
|
"UnescapeLocale": func(str string) string {
|
||||||
return strings.NewReplacer("\\;", ";", "\\#", "#").Replace(str)
|
return strings.NewReplacer("\\;", ";", "\\#", "#").Replace(str)
|
||||||
},
|
},
|
||||||
|
"Escape": Escape,
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +182,11 @@ func Str2html(raw string) template.HTML {
|
||||||
return template.HTML(markup.Sanitize(raw))
|
return template.HTML(markup.Sanitize(raw))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Escape escapes a HTML string
|
||||||
|
func Escape(raw string) string {
|
||||||
|
return html.EscapeString(raw)
|
||||||
|
}
|
||||||
|
|
||||||
// List traversings the list
|
// List traversings the list
|
||||||
func List(l *list.List) chan interface{} {
|
func List(l *list.List) chan interface{} {
|
||||||
e := l.Front()
|
e := l.Front()
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{if .Keyword}}
|
{{if .Keyword}}
|
||||||
<h3>
|
<h3>
|
||||||
{{.i18n.Tr "repo.search.results" .Keyword .RepoLink .RepoName | Str2html}}
|
{{.i18n.Tr "repo.search.results" (.Keyword|Escape) .RepoLink .RepoName | Str2html }}
|
||||||
</h3>
|
</h3>
|
||||||
<div class="repository search">
|
<div class="repository search">
|
||||||
{{range $result := .SearchResults}}
|
{{range $result := .SearchResults}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user