From 65c940f66cb525ccdaca6f80fea8f7555ce833dc Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 20 Feb 2021 04:26:57 +0000 Subject: [PATCH] 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 Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: techknowlogick --- modules/context/context.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/context/context.go b/modules/context/context.go index bc48c1415d..ea267dfb3f 100644 --- a/modules/context/context.go +++ b/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" } 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) } }