mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	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 <art27@cantab.net>
This commit is contained in:
		@@ -86,11 +86,12 @@ func getDirAssetNames(dir string) []string {
 | 
				
			|||||||
// HTMLRenderer returns a render.
 | 
					// HTMLRenderer returns a render.
 | 
				
			||||||
func HTMLRenderer() *render.Render {
 | 
					func HTMLRenderer() *render.Render {
 | 
				
			||||||
	return render.New(render.Options{
 | 
						return render.New(render.Options{
 | 
				
			||||||
		Extensions:    []string{".tmpl"},
 | 
							Extensions:                []string{".tmpl"},
 | 
				
			||||||
		Directory:     "templates",
 | 
							Directory:                 "templates",
 | 
				
			||||||
		Funcs:         NewFuncMap(),
 | 
							Funcs:                     NewFuncMap(),
 | 
				
			||||||
		Asset:         GetAsset,
 | 
							Asset:                     GetAsset,
 | 
				
			||||||
		AssetNames:    GetAssetNames,
 | 
							AssetNames:                GetAssetNames,
 | 
				
			||||||
		IsDevelopment: !setting.IsProd(),
 | 
							IsDevelopment:             !setting.IsProd(),
 | 
				
			||||||
 | 
							DisableHTTPErrorRendering: true,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user