Defect #37138

Mentions of users with "@" in their username

Added by David Robinson 4 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Email notifications
Target version:5.0.2
Resolution:Fixed Affected version:5.0.0

Description

When mentioning a user that has an "@" in their username no email is sent to the user.

Associated revisions

Revision 21660
Added by Marius BALTEANU 3 months ago

Fix mentions of users with "@" in their username not working (#37138).

Revision 21664
Added by Marius BALTEANU 3 months ago

Fix random failing test (#37138).

Revision 21665
Added by Marius BALTEANU 3 months ago

Merged r21660 to 5.0-stable (#37138).

Revision 21666
Added by Marius BALTEANU 3 months ago

Merged r21664 to 5.0-stable (#37138).

History

#1 Updated by David Robinson 4 months ago

Usernames here are often of the form:

#2 Updated by VD DV 4 months ago

We have same behavior at our 5.0 installation.

#3 Updated by David Robinson 4 months ago

VD DV wrote:

We have same behavior at our 5.0 installation.

In case you want a workaround while this is fixed, I have made the following in a "plugin" to fix it here:

Redmine::Acts::Mentionable::InstanceMethods.module_eval do
        def scan_for_mentioned_users(content)
          return [] if content.nil?

          # remove quoted text
          content = content.gsub(%r{\r\n(?:\>\s)+(.*?)\r\n}m, '')

          text_formatting = Setting.text_formatting
          # Remove text wrapped in pre tags based on text formatting
          case text_formatting
          when 'textile'
            content = content.gsub(%r{<pre>(.*?)</pre>}m, '')
          when 'markdown', 'common_mark'
            content = content.gsub(%r{(~~~|```)(.*?)(~~~|```)}m, '')
          end

          users = 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
        (?=
            \.+[ \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
        )
    /ix
end


This works here, but I have no idea if there are some quirky edge-cases where it might break.
You can either make a plugin with it, or just patch the lib/redmine/acts/mentionable file.

#4 Updated by Marius BALTEANU 4 months ago

  • Assignee set to Marius BALTEANU
  • Target version set to 5.0.2

#5 Updated by Marius BALTEANU 3 months ago

  • Category set to Email notifications
  • Status changed from New to Resolved
  • Resolution set to Fixed

Fix committed. I've reused the Regex from user links.

#6 Updated by Marius BALTEANU 3 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF