refactor: markup render (#38864)

1. add missing CSP header to api & web render endpoints.
2. make jupyter render skip post-processors, nothing to process
3. make ShortLinkProcessor correctly validate URL schemes and respect
the CustomURLSchemes setting
This commit is contained in:
wxiaoguang
2026-08-12 00:01:02 +08:00
committed by GitHub
parent eeeb5d7c7b
commit 938cde959e
25 changed files with 255 additions and 172 deletions
+2 -3
View File
@@ -16,6 +16,7 @@ import (
"time"
"gitea.dev/modules/htmlutil"
"gitea.dev/modules/markup/common"
"gitea.dev/modules/markup/internal"
"gitea.dev/modules/public"
"gitea.dev/modules/setting"
@@ -303,9 +304,7 @@ func RenderWithRenderer(ctx *RenderContext, renderer Renderer, input io.Reader,
// Init initializes the render global variables
func Init(renderHelpFuncs *RenderHelperFuncs) {
DefaultRenderHelperFuncs = renderHelpFuncs
if len(setting.Markdown.CustomURLSchemes) > 0 {
CustomLinkURLSchemes(setting.Markdown.CustomURLSchemes)
}
common.InitLinkURLSchemes(setting.Markdown.CustomURLSchemes)
// since setting maybe changed extensions, this will reload all renderer extensions mapping
fileNameRenderers = make(map[string]Renderer)