Skip to content

Commit d644e88

Browse files
thehowllafriks
authored andcommitted
HTML escape all lines of the search result (#3402)
Fixes #3383.
1 parent 00d0847 commit d644e88

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/search/search.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package search
66

77
import (
88
"bytes"
9+
"html"
910
gotemplate "html/template"
1011
"strings"
1112

@@ -75,17 +76,17 @@ func searchResult(result *indexer.RepoSearchResult, startIndex, endIndex int) (*
7576
closeActiveIndex := util.Min(result.EndIndex-index, len(line))
7677
err = writeStrings(&formattedLinesBuffer,
7778
`<li>`,
78-
line[:openActiveIndex],
79+
html.EscapeString(line[:openActiveIndex]),
7980
`<span class='active'>`,
80-
line[openActiveIndex:closeActiveIndex],
81+
html.EscapeString(line[openActiveIndex:closeActiveIndex]),
8182
`</span>`,
82-
line[closeActiveIndex:],
83+
html.EscapeString(line[closeActiveIndex:]),
8384
`</li>`,
8485
)
8586
} else {
8687
err = writeStrings(&formattedLinesBuffer,
8788
`<li>`,
88-
line,
89+
html.EscapeString(line),
8990
`</li>`,
9091
)
9192
}

0 commit comments

Comments
 (0)