1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-26 03:21:33 +03:00

HTML escape all lines of the search result (#3402)

Fixes #3383.
This commit is contained in:
Morgan Bazalgette 2018-01-22 22:28:16 +01:00 committed by Lauris BH
parent 00d08473b8
commit d644e88107

View File

@ -6,6 +6,7 @@ package search
import (
"bytes"
"html"
gotemplate "html/template"
"strings"
@ -75,17 +76,17 @@ func searchResult(result *indexer.RepoSearchResult, startIndex, endIndex int) (*
closeActiveIndex := util.Min(result.EndIndex-index, len(line))
err = writeStrings(&formattedLinesBuffer,
`<li>`,
line[:openActiveIndex],
html.EscapeString(line[:openActiveIndex]),
`<span class='active'>`,
line[openActiveIndex:closeActiveIndex],
html.EscapeString(line[openActiveIndex:closeActiveIndex]),
`</span>`,
line[closeActiveIndex:],
html.EscapeString(line[closeActiveIndex:]),
`</li>`,
)
} else {
err = writeStrings(&formattedLinesBuffer,
`<li>`,
line,
html.EscapeString(line),
`</li>`,
)
}