]> source.dussan.org Git - gitea.git/commitdiff
Prevent endless loop if templates missing (#14752)
authorzeripath <art27@cantab.net>
Sat, 20 Feb 2021 04:26:57 +0000 (04:26 +0000)
committerGitHub <noreply@github.com>
Sat, 20 Feb 2021 04:26:57 +0000 (12:26 +0800)
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>
modules/context/context.go

index bc48c1415de2d49217ead311d4e685137e6685e3..ea267dfb3fc64e55a070e9c7ee9aeb64d290350e 100644 (file)
@@ -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)
        }
 }