]> source.dussan.org Git - gitea.git/commitdiff
Prevent template renderer from rendering error (#14646)
authorzeripath <art27@cantab.net>
Sat, 13 Feb 2021 19:41:53 +0000 (19:41 +0000)
committerGitHub <noreply@github.com>
Sat, 13 Feb 2021 19:41:53 +0000 (19:41 +0000)
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 <art27@cantab.net>
modules/templates/base.go

index ff31c12899408b8dd59f715b1ec01596d88ae388..cb83143bd3424894384fdf6cb52cab8713a7ca0b 100644 (file)
@@ -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,
        })
 }