summaryrefslogtreecommitdiffstats
path: root/modules/markup
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-08-28 21:15:56 +0100
committerGitHub <noreply@github.com>2021-08-28 21:15:56 +0100
commitc9c0475f4d664766c174a4563ba9ec210cadfeac (patch)
tree817ae8782c3510cc14c1dc91f4cd821f0dea8e5a /modules/markup
parent90c01804470f45018de0653a19d5211c986c035c (diff)
downloadgitea-c9c0475f4d664766c174a4563ba9ec210cadfeac.tar.gz
gitea-c9c0475f4d664766c174a4563ba9ec210cadfeac.zip
In Render tolerate not being passed a context (#16842)
* In Render tolerate not being passed a context It is possible for RenderString to be passed to an external renderer if markdown is set to be rendered by an external renderer. No context is currently sent to these meaning that this will error out. Fix #16835 Signed-off-by: Andrew Thornton <art27@cantab.net> * Add Context to Repo calls for RenderString All calls from routers can easily add the context - so add it. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/markup')
-rw-r--r--modules/markup/external/external.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go
index 52139f5a49..f7be06dbe9 100644
--- a/modules/markup/external/external.go
+++ b/modules/markup/external/external.go
@@ -14,6 +14,7 @@ import (
"runtime"
"strings"
+ "code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/process"
@@ -99,7 +100,12 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
}
if ctx == nil || ctx.Ctx == nil {
- return fmt.Errorf("RenderContext did not provide context")
+ if ctx == nil {
+ log.Warn("RenderContext not provided defaulting to empty ctx")
+ ctx = &markup.RenderContext{}
+ }
+ log.Warn("RenderContext did not provide context, defaulting to Shutdown context")
+ ctx.Ctx = graceful.GetManager().ShutdownContext()
}
processCtx, cancel := context.WithCancel(ctx.Ctx)