1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-11 03:33:07 +00:00

Merged r21660 to 5.0-stable (#37138).

git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21665 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2022-06-20 15:17:00 +00:00
parent 9713c6b270
commit 3e12fc1831
2 changed files with 19 additions and 9 deletions

View File

@ -90,19 +90,20 @@ module Redmine
content = content.gsub(%r{(~~~|```)(.*?)(~~~|```)}m, '')
end
users = content.scan(MENTION_PATTERN).flatten
content.scan(MENTION_PATTERN).flatten
end
MENTION_PATTERN = /
(?:^|\W) # beginning of string or non-word char
@((?>[a-z0-9][a-z0-9-]*)) # @username
(?!\/) # without a trailing slash
(?:^|\W)
@([A-Za-z0-9_\-@\.]*?)
(?=
\.+[ \t\W]| # dots followed by space or non-word character
\.+$| # dots at end of line
[^0-9a-zA-Z_.]| # non-word character except dot
$ # end of line
)
(?=[[:punct:]][^A-Za-z0-9_\/])|
,|
\.+$|
\s|
\]|
<|
$)
/ix
end
end

View File

@ -34,6 +34,15 @@ class Redmine::Acts::MentionableTest < ActiveSupport::TestCase
assert_equal [User.find(3)], issue.mentioned_users
end
def test_mentioned_users_with_user_mention_having_mail_as_login
user = User.generate!(login: "foo@example.net")
User.add_to_project(user, Project.find(1), Role.find(1))
issue = Issue.generate!(project_id: 1, description: '@dlopper and @foo@example.net')
assert_equal [User.find(3), user], issue.mentioned_users
end
def test_mentioned_users_with_multiple_mentions
issue = Issue.generate!(project_id: 1, description: 'Hello @dlopper, @jsmith.')