diff options
author | KN4CK3R <admin@oldschoolhack.me> | 2024-01-27 04:36:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-27 11:36:01 +0800 |
commit | 01acd1eea38f25d2b21f56ec15dd162ca6005fbf (patch) | |
tree | 253474e7a8fa2f7bc5aaf0421475562a9513575a /modules/markup/markdown/goldmark.go | |
parent | a240d5dfa7e261f2fb703cf24b1ba4dc6aa47bfd (diff) | |
download | gitea-01acd1eea38f25d2b21f56ec15dd162ca6005fbf.tar.gz gitea-01acd1eea38f25d2b21f56ec15dd162ca6005fbf.zip |
Strip `/` from relative links (#28932)
Fixes #28915
Restores the old behaviour:
https://github.com/go-gitea/gitea/pull/26745/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59L96
Diffstat (limited to 'modules/markup/markdown/goldmark.go')
-rw-r--r-- | modules/markup/markdown/goldmark.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go index 1db3cbad7e..3dc5530e00 100644 --- a/modules/markup/markdown/goldmark.go +++ b/modules/markup/markdown/goldmark.go @@ -85,9 +85,11 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa // 2. If they're not wrapped with a link they need a link wrapper // Check if the destination is a real link - link := v.Destination - if len(link) > 0 && !markup.IsLink(link) { - v.Destination = []byte(giteautil.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), string(link))) + if len(v.Destination) > 0 && !markup.IsLink(v.Destination) { + v.Destination = []byte(giteautil.URLJoin( + ctx.Links.ResolveMediaLink(ctx.IsWiki), + strings.TrimLeft(string(v.Destination), "/"), + )) } parent := n.Parent() @@ -103,7 +105,7 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa // Duplicate the current image node image := ast.NewImage(ast.NewLink()) - image.Destination = link + image.Destination = v.Destination image.Title = v.Title for _, attr := range v.Attributes() { image.SetAttribute(attr.Name, attr.Value) |