Project

General

Profile

Actions

Defect #37138

closed

Mentions of users with "@" in their username

Added by David Robinson almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Email notifications
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

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

Actions #1

Updated by David Robinson almost 2 years ago

Usernames here are often of the form:

Actions #2

Updated by VD DV almost 2 years ago

We have same behavior at our 5.0 installation.

Actions #3

Updated by David Robinson almost 2 years 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.
Actions #4

Updated by Marius BĂLTEANU over 1 year ago

  • Assignee set to Marius BĂLTEANU
  • Target version set to 5.0.2
Actions #5

Updated by Marius BĂLTEANU over 1 year 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.

Actions #6

Updated by Marius BĂLTEANU over 1 year ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF