As designed Usernames of length 1 are not mentionable

Affected version
2.2.5

Xon

Well-known member
A username with a length of 1 character is not mentionable as the regex either extracts an additional space or just misses it.

Given the message;
@a @a @cc

XF will generate the query;
SQL:
SELECT user.user_id, user.username,
IF(user.username LIKE 'a %', 1, 0) AS match_0, 
IF(user.username LIKE 'a %', 1, 0) AS match_1, 
IF(user.username LIKE 'cc%', 1, 0) AS match_2
FROM xf_user AS user
WHERE (user.username LIKE 'a %' OR user.username LIKE 'b %' OR user.username LIKE 'cc%')
ORDER BY LENGTH(user.username) DESC

A username with length of 1 also fails to be extracted if it is the last bit of text in the message;

Given the message;

SQL:
SELECT user.user_id, user.username,
IF(user.username LIKE 'a %', 1, 0) AS match_0, 
IF(user.username LIKE 'a %', 1, 0) AS match_1,
FROM xf_user AS user
WHERE (user.username LIKE 'a %' OR user.username LIKE 'b %')
ORDER BY LENGTH(user.username) DESC

The default configuration for a minimum username length of 3, which will thankfully migrate this for most sites
 

Mike

XenForo developer
Staff member
At this time, I don't think we're going to change anything here. The challenge with mentions is that usernames are entirely arbitrary strings that may include whitespace, for example (and other weird characters). Thus, we have to make some guesses. There is also a compromise in terms of trying to make the match list be as specific as possible to avoid fetching too many names. Allowing a 1 character match is likely to trigger situations that require testing against a huge number of username matches (every name that starts with "a" in this case), whereas a 2 character match can significantly reduce that amount.
 
Top