From: zeripath Date: Sat, 13 Feb 2021 19:41:53 +0000 (+0000) Subject: Prevent template renderer from rendering error (#14646) X-Git-Tag: v1.15.0-dev~186 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c9f1baf62024017f1dfb2f582252978828a92f15;p=gitea.git Prevent template renderer from rendering error (#14646) When there is a panic during template rendering unrolled/render will automatically render the error. This leads to the panic being displayed in the page and not a 500 page Fix #14467 Fix #14525 Signed-off-by: Andrew Thornton --- diff --git a/modules/templates/base.go b/modules/templates/base.go index ff31c12899..cb83143bd3 100644 --- a/modules/templates/base.go +++ b/modules/templates/base.go @@ -86,11 +86,12 @@ func getDirAssetNames(dir string) []string { // HTMLRenderer returns a render. func HTMLRenderer() *render.Render { return render.New(render.Options{ - Extensions: []string{".tmpl"}, - Directory: "templates", - Funcs: NewFuncMap(), - Asset: GetAsset, - AssetNames: GetAssetNames, - IsDevelopment: !setting.IsProd(), + Extensions: []string{".tmpl"}, + Directory: "templates", + Funcs: NewFuncMap(), + Asset: GetAsset, + AssetNames: GetAssetNames, + IsDevelopment: !setting.IsProd(), + DisableHTTPErrorRendering: true, }) }