mirror of
https://github.com/go-gitea/gitea
synced 2025-07-05 18:17:19 +00:00
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>
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user