Skip to content

Commit

Permalink
Prevent endless loop if templates missing (#14752)
Browse files Browse the repository at this point in the history
Since the chi upgrade if the templates are missing an endless loop will occur if
status/500.tmpl is missing.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
  • Loading branch information
3 people committed Feb 20, 2021
1 parent 91424ff commit 65c940f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/context/context.go
Expand Up @@ -188,6 +188,10 @@ func (ctx *Context) HTML(status int, name base.TplName) {
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
}
if err := ctx.Render.HTML(ctx.Resp, status, string(name), ctx.Data); err != nil {
if status == http.StatusInternalServerError && name == base.TplName("status/500") {
ctx.PlainText(http.StatusInternalServerError, []byte("Unable to find status/500 template"))
return
}
ctx.ServerError("Render failed", err)
}
}
Expand Down

0 comments on commit 65c940f

Please sign in to comment.