Prevent endless loop if templates missing (#14752)

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>
tokarchuk/v1.17
zeripath 4 years ago committed by GitHub
parent 91424fff3d
commit 65c940f66c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      modules/context/context.go

@ -188,6 +188,10 @@ func (ctx *Context) HTML(status int, name base.TplName) {
return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
} }
if err := ctx.Render.HTML(ctx.Resp, status, string(name), ctx.Data); err != nil { 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) ctx.ServerError("Render failed", err)
} }
} }

Loading…
Cancel
Save