From 46a4c6835daf4642074bb1a18a3210b03a64259b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 12 Jul 2021 23:13:59 +0200 Subject: [PATCH] Fix external renderer (#16401) * fix external renderer * use GBackground context as fallback * no fallback, return error Co-authored-by: Lauris BH --- modules/markup/external/external.go | 4 ++++ routers/web/repo/view.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go index e35a1b99c..52139f5a4 100644 --- a/modules/markup/external/external.go +++ b/modules/markup/external/external.go @@ -98,6 +98,10 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io. args = append(args, f.Name()) } + if ctx == nil || ctx.Ctx == nil { + return fmt.Errorf("RenderContext did not provide context") + } + processCtx, cancel := context.WithCancel(ctx.Ctx) defer cancel() diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index cf076bdf1..21bd80c40 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -336,6 +336,7 @@ func renderDirectory(ctx *context.Context, treeLink string) { ctx.Data["MarkupType"] = string(markupType) var result strings.Builder err := markup.Render(&markup.RenderContext{ + Ctx: ctx, Filename: readmeFile.name, URLPrefix: readmeTreelink, Metas: ctx.Repo.Repository.ComposeDocumentMetas(), @@ -511,6 +512,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["MarkupType"] = markupType var result strings.Builder err := markup.Render(&markup.RenderContext{ + Ctx: ctx, Filename: blob.Name(), URLPrefix: path.Dir(treeLink), Metas: ctx.Repo.Repository.ComposeDocumentMetas(), @@ -570,6 +572,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["MarkupType"] = markupType var result strings.Builder err := markup.Render(&markup.RenderContext{ + Ctx: ctx, Filename: blob.Name(), URLPrefix: path.Dir(treeLink), Metas: ctx.Repo.Repository.ComposeDocumentMetas(),