summaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-02-20 04:26:57 +0000
committerGitHub <noreply@github.com>2021-02-20 12:26:57 +0800
commit65c940f66cb525ccdaca6f80fea8f7555ce833dc (patch)
tree2db1cafa3e7232669b2761cb08922d5209fd2962 /modules/context
parent91424fff3def09970c71c5725643daa4c5b141de (diff)
downloadgitea-65c940f66cb525ccdaca6f80fea8f7555ce833dc.tar.gz
gitea-65c940f66cb525ccdaca6f80fea8f7555ce833dc.zip
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>
Diffstat (limited to 'modules/context')
-rw-r--r--modules/context/context.go4
1 files changed, 4 insertions, 0 deletions
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)
}
}