A lone @ gets autocompleted to the next mention


(from TDWTF) #1

If this is already reported, I didn’t find it. Searching for this kind of bug is pretty hard, though, since it centers around a single character.

Bug: A single “at” inside a paragraph with multiple “at” turns into the nearest mention.
Expected result: Posting a single “at” with a whitespace behind it does not get turned into a mention
Actual Result: The “at” gets turned into the next mention in the paragraph (not seperated by 2 newlines).
Reproduction steps:
@ so this is a single “at”
@sam This is me mentioning Sam

@sam This is me mentioning Sam```

__Bonus Bug:__ it also deletes following X characters (where X is the amount of characters in the mentioned username)

(Jeff Atwood) #2

Nope, pretty sure I have not seen that one before. Good find!


(Jens Maier) #3
word @ one @ word
@mention

The inline parser hands "@ one @ word\n@mention" to the inlineRegex helper which applies the matcher regex. The regex is defined as /^.../m, so the ^ anchor matches just after \n causing the pattern to match at @mention.

https://github.com/discourse/discourse/pull/3424

The regex really should only match on start of string, not after each inline \n


(Régis Hanol) #4