Fix panic in blame view when a file has only a single commit (#36230)
This PR fixes a panic in the repository blame view that occurs when rendering files whose blame history consists of only a single commit.
This commit is contained in:
@@ -271,7 +271,7 @@ func renderBlame(ctx *context.Context, blameParts []*gitrepo.BlamePart, commitNa
|
|||||||
unsafeLines := highlight.UnsafeSplitHighlightedLines(highlighted)
|
unsafeLines := highlight.UnsafeSplitHighlightedLines(highlighted)
|
||||||
for i, br := range rows {
|
for i, br := range rows {
|
||||||
var line template.HTML
|
var line template.HTML
|
||||||
if i < len(rows) {
|
if i < len(unsafeLines) {
|
||||||
line = template.HTML(util.UnsafeBytesToString(unsafeLines[i]))
|
line = template.HTML(util.UnsafeBytesToString(unsafeLines[i]))
|
||||||
}
|
}
|
||||||
br.EscapeStatus, br.Code = charset.EscapeControlHTML(line, ctx.Locale)
|
br.EscapeStatus, br.Code = charset.EscapeControlHTML(line, ctx.Locale)
|
||||||
|
|||||||
Reference in New Issue
Block a user