Forum Replies Created

Viewing 5 replies - 16 through 20 (of 20 total)
  • Thread Starter evanhgh

    (@evanhgh)

    Hello just checking in for an update on this, have you been able to reproduce this bug?

    Thread Starter evanhgh

    (@evanhgh)

    Hey just checking in, have we made any progress on the issue of mentioning users with emails as their username?

    Thread Starter evanhgh

    (@evanhgh)

    The problem seems to be how the plugin is parsing usernames. It’s assuming that usernames are simple alphanumeric strings, and thus it’s interpreting any “@” sign as the beginning of a mention. If a username has an “@” sign in it (as in an email address), it incorrectly breaks the mention.

    Could we solve this problem by changing the username pattern that we match when searching for mentions. Instead of treating every “@” sign as the start of a mention, we could first check if it’s not already part of an email address?

    Specifically, in the class-comment-mention.php file

    public static function cmt_mntn_find_mentions( $content ) {
    
    $pattern = '/[@]+([A-Za-z0-9-_\.@]+)\b/';
    		preg_match_all( $pattern, $content, $usernames );
    
    //rest of code

    to

    public static function cmt_mntn_find_mentions( $content ) {
    
        // Do not consider email addresses as mentions
        $pattern = '/(?<![A-Za-z0-9-_.])[.@]([A-Za-z0-9-_\.@]+)\b/';
        preg_match_all( $pattern, $content, $usernames );
    
        // rest of code
    
    

    This change to the regular expression MIGHT ensure that an “@” character isn’t treated as a mention if it’s preceded by an alphanumeric character, hyphen, underscore, or period – (the valid characters in an email username)

    the addition of this negative-lookbehind-assertion would be more precise because it tries to exclude matches that are part of an email address. This is useful when trying to ignore email addresses when searching for “mentions” and only want to capture instances where usernames are mentioned with a preceding @ symbol.

    I have not familiarized myself with the rest of the code so this could very well break it more. no idea.

    EDIT:
    Nevermind that didnt work in my staging site, please ignore the suggestion lol

    • This reply was modified 1 year, 9 months ago by evanhgh.
    Thread Starter evanhgh

    (@evanhgh)

    Hi Bunty,

    Unfortunately, this is still an issue.

    If a user has an “@” symbol in their username it is not possible to mention them.

    It seems that the update has broken the functionality entirely.

    Now there is no dropdown in bbpress when using the @ symbol

Viewing 5 replies - 16 through 20 (of 20 total)