]> source.dussan.org Git - gitea.git/commitdiff
Fix external renderer (#16401)
author6543 <6543@obermui.de>
Mon, 12 Jul 2021 21:13:59 +0000 (23:13 +0200)
committerGitHub <noreply@github.com>
Mon, 12 Jul 2021 21:13:59 +0000 (17:13 -0400)
* fix external renderer

* use GBackground context as fallback

* no fallback, return error

Co-authored-by: Lauris BH <lauris@nix.lv>
modules/markup/external/external.go
routers/web/repo/view.go

index e35a1b99c0fd83497d8146c049637b5e57014b81..52139f5a49c3cd709f8824d89525be49e191f6f6 100644 (file)
@@ -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()
 
index cf076bdf1a839af389acfa90ec0f4032bd101385..21bd80c406673ddb5eaf81094231e21e2f302217 100644 (file)
@@ -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(),