Skip to content

Commit

Permalink
HTML escape all lines of the search result (gogs#3402)
Browse files Browse the repository at this point in the history
Fixes gogs#3383.
  • Loading branch information
thehowl authored and lafriks committed Jan 22, 2018
1 parent 00d0847 commit d644e88
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package search

import (
"bytes"
"html"
gotemplate "html/template"
"strings"

Expand Down Expand Up @@ -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>`,
)
}
Expand Down

0 comments on commit d644e88

Please sign in to comment.