@@ -76,7 +76,7 @@ func IsReadmeFile(name string) bool {
7676
7777var (
7878 // MentionPattern matches string that mentions someone, e.g. @Unknwon
79- MentionPattern = regexp .MustCompile (`(\s|^)@[0-9a-zA-Z-_\.]+` )
79+ MentionPattern = regexp .MustCompile (`(\s|^|\W )@[0-9a-zA-Z-_\.]+` )
8080
8181 // CommitPattern matches link to certain commit with or without trailing hash,
8282 // e.g. https://try.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2
@@ -101,7 +101,7 @@ var (
101101func FindAllMentions (content string ) []string {
102102 mentions := MentionPattern .FindAllString (content , - 1 )
103103 for i := range mentions {
104- mentions [i ] = strings .TrimSpace (mentions [i ])[ 1 :] // Strip @ character
104+ mentions [i ] = mentions [ i ][ strings .Index (mentions [i ], "@" ) + 1 :] // Strip @ character
105105 }
106106 return mentions
107107}
@@ -275,7 +275,7 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
275275func RenderSpecialLink (rawBytes []byte , urlPrefix string , metas map [string ]string ) []byte {
276276 ms := MentionPattern .FindAll (rawBytes , - 1 )
277277 for _ , m := range ms {
278- m = bytes .TrimSpace ( m )
278+ m = m [ bytes .Index ( m , [] byte ( "@" )):]
279279 rawBytes = bytes .Replace (rawBytes , m ,
280280 []byte (fmt .Sprintf (`<a href="%s/%s">%s</a>` , setting .AppSubUrl , m [1 :], m )), - 1 )
281281 }
0 commit comments