summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorMichael Dyrynda <deringer@iatstuti.net>2015-01-03 22:03:41 +1030
committerMichael Dyrynda <deringer@iatstuti.net>2015-01-03 22:03:41 +1030
commitc7cbdd34fb7ecb1c06ef00e17d0d289774899c5b (patch)
tree39006e0e72b910837a5883b16b71d26761400201 /modules/base
parentd5c6b535715c9c791f6cff7e19c66cedd089c6d2 (diff)
downloadgitea-c7cbdd34fb7ecb1c06ef00e17d0d289774899c5b.tar.gz
gitea-c7cbdd34fb7ecb1c06ef00e17d0d289774899c5b.zip
Adjust MentionPattern to not match users mid-sentence (or email addresses)
Fix link to user profile, update based on adjusted MentionPattern
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/markdown.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index b2f94c480b..f18d459ff6 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -100,7 +100,7 @@ func (options *CustomRender) Image(out *bytes.Buffer, link []byte, title []byte,
}
var (
- MentionPattern = regexp.MustCompile(`@[0-9a-zA-Z_]{1,}`)
+ MentionPattern = regexp.MustCompile(`(\s@)[0-9a-zA-Z_]{1,}`)
commitPattern = regexp.MustCompile(`(\s|^)https?.*commit/[0-9a-zA-Z]+(#+[0-9a-zA-Z-]*)?`)
issueFullPattern = regexp.MustCompile(`(\s|^)https?.*issues/[0-9]+(#+[0-9a-zA-Z-]*)?`)
issueIndexPattern = regexp.MustCompile(`#[0-9]+`)
@@ -123,7 +123,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte {
ms := MentionPattern.FindAll(line, -1)
for _, m := range ms {
line = bytes.Replace(line, m,
- []byte(fmt.Sprintf(`<a href="%s/user/%s">%s</a>`, setting.AppSubUrl, m[1:], m)), -1)
+ []byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubUrl, m[2:], m)), -1)
}
}