File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import (
2727 "golang.org/x/net/html/charset"
2828 "golang.org/x/text/transform"
2929 "gopkg.in/editorconfig/editorconfig-core-go.v1"
30+ "html"
3031)
3132
3233// NewFuncMap returns functions for injecting to templates
@@ -179,6 +180,7 @@ func NewFuncMap() []template.FuncMap {
179180 return dict , nil
180181 },
181182 "Printf" : fmt .Sprintf ,
183+ "Escape" : Escape ,
182184 }}
183185}
184186
@@ -197,6 +199,11 @@ func Str2html(raw string) template.HTML {
197199 return template .HTML (markup .Sanitize (raw ))
198200}
199201
202+ // Escape escapes a HTML string
203+ func Escape (raw string ) string {
204+ return html .EscapeString (raw )
205+ }
206+
200207// List traversings the list
201208func List (l * list.List ) chan interface {} {
202209 e := l .Front ()
Original file line number Diff line number Diff line change 1414 </div>
1515 {{if .Keyword}}
1616 <h3>
17- {{.i18n.Tr "repo.search.results" .Keyword .RepoLink .RepoName | Str2html}}
17+ {{.i18n.Tr "repo.search.results" ( .Keyword|Escape) .RepoLink .RepoName | Str2html }}
1818 </h3>
1919 <div class="repository search">
2020 {{range $result := .SearchResults}}
You can’t perform that action at this time.
0 commit comments