aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup/html.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-07-04 10:26:04 +0100
committerGitHub <noreply@github.com>2021-07-04 10:26:04 +0100
commit32fd11395b7631cd226783a98b86e55192bd99ca (patch)
tree57a9010bd52a9890e88a320668bb80d2747d1540 /modules/markup/html.go
parentfae07cbc8fece383c88ed7b13474a94133c4accf (diff)
downloadgitea-32fd11395b7631cd226783a98b86e55192bd99ca.tar.gz
gitea-32fd11395b7631cd226783a98b86e55192bd99ca.zip
Fix relative links in postprocessed images (#16334)
If a pre-post-processed file contains relative img tags these need to be updated and joined correctly with the prefix. Finally, the node attributes need to be updated. Fix #16308 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r--modules/markup/html.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index 1e55629ab5..7afd8114c1 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -364,7 +364,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node, visitText
}
case html.ElementNode:
if node.Data == "img" {
- for _, attr := range node.Attr {
+ for i, attr := range node.Attr {
if attr.Key != "src" {
continue
}
@@ -377,6 +377,7 @@ func visitNode(ctx *RenderContext, procs []processor, node *html.Node, visitText
attr.Val = util.URLJoin(prefix, attr.Val)
}
+ node.Attr[i] = attr
}
} else if node.Data == "a" {
visitText = false