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>
mj-v1.14.3
zeripath 3 years ago committed by GitHub
parent 91424fff3d
commit 65c940f66c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)
}
}

Loading…
Cancel
Save