aboutsummaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorHowl <git@howl.moe>2015-11-15 22:22:25 +0100
committerHowl <git@howl.moe>2015-11-15 22:22:25 +0100
commitca5678da3268706b8516a52ef945742792c297a0 (patch)
tree9c516f9405fe2dfcefb99b1e08c278afd111599e /modules/base
parent85c58eba902b554822666acec78046379a17b598 (diff)
downloadgitea-ca5678da3268706b8516a52ef945742792c297a0.tar.gz
gitea-ca5678da3268706b8516a52ef945742792c297a0.zip
Safely detect urlPrefix in the format /:owner/:repo
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/markdown.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index 70c2918af0..9d297f0ce8 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -168,9 +168,9 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
}
func RenderIssueIndexPattern(rawBytes []byte, urlPrefix string) []byte {
- // Remove unnecessary things after username and reponame in prefix
- // (otherwise stuff like /:user/:repo/src/master/issues/1 would happen)
- urlPrefix = strings.Join(strings.Split(urlPrefix, "/")[:3], "/")
+ if i := strings.Index(urlPrefix, "/src"); i != -1 {
+ urlPrefix = urlPrefix[:i]
+ }
ms := issueIndexPattern.FindAll(rawBytes, -1)
for _, m := range ms {
var space string