summaryrefslogtreecommitdiffstats
path: root/modules/markup/markdown/goldmark.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-04-10 17:26:28 +0100
committerGitHub <noreply@github.com>2021-04-11 00:26:28 +0800
commitc680eb2cc74823f017f5ad5a4c9e8094cde311f4 (patch)
tree3da6565c502b958292a61b1f3272fa7ef51d3b2d /modules/markup/markdown/goldmark.go
parent84f5a0bc62568b6d0a67969e460f4d41339a07d6 (diff)
downloadgitea-c680eb2cc74823f017f5ad5a4c9e8094cde311f4.tar.gz
gitea-c680eb2cc74823f017f5ad5a4c9e8094cde311f4.zip
Links in markdown should be absolute to the repository not the server (#15088)
* Links in markdown should be absolute to the repository not the server Fix #15075 Signed-off-by: Andrew Thornton <art27@cantab.net> * match github Signed-off-by: Andrew Thornton <art27@cantab.net> * add testcase Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/markup/markdown/goldmark.go')
-rw-r--r--modules/markup/markdown/goldmark.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/modules/markup/markdown/goldmark.go b/modules/markup/markdown/goldmark.go
index 07e2e36e1d..ad77177db4 100644
--- a/modules/markup/markdown/goldmark.go
+++ b/modules/markup/markdown/goldmark.go
@@ -98,7 +98,8 @@ func (g *ASTTransformer) Transform(node *ast.Document, reader text.Reader, pc pa
}
prefix = strings.Replace(prefix, "/src/", "/media/", 1)
- lnk := string(link)
+ lnk := strings.TrimLeft(string(link), "/")
+
lnk = giteautil.URLJoin(prefix, lnk)
link = []byte(lnk)
}