# Mentiong usernames with trailing underscore does not work

**URL:** https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290
**Category:** Bug
**Tags:** markdown
**Created:** [October 8, 2015, 9:38pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290 "2015-10-08T21:38:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Blaisorblade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blaisorblade/32/107357_2.png) [@Blaisorblade](https://meta.discourse.org/u/Blaisorblade)
#### Post date: [October 8, 2015, 9:38pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290/1 "2015-10-08T21:38:38Z")

</div>

Continuing the discussion from [UserNameSuggester suggests names with trailing underscores](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964/3):

> [@UserNameSuggester suggests names with trailing underscores](https://meta.discourse.org/t/usernamesuggester-suggests-names-with-trailing-underscores/32964/3):
>
> Trailing underscore in username is now allowed:
> 
> [FIX: Allow trailing `_` because we used to. · discourse/discourse@b3d2982 · GitHub](https://github.com/discourse/discourse/commit/b3d2982be7d40ff632afcd1c3cbe8c9e78a632be)

But can you mention with `@` a username ending in `_`? With Discourse 1.4.1 it doesn’t seem to work, or at least the preview doesn’t format the attempted mention as a mention. If then you use `@username_, @another_user` (without a space between underscore and comma, and with another underscore-containing username afterwards), things work even less well — the text between underscores is formatted in italic (because Markdown parsing triggers), and both mentions break. This bug is triggered when expanding `@group`, with a group containing such usernames; the usernames happen to be output in that bug-triggering order.

---

<div class="post-metadata">

### Author: ![Izzion](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/izzion/32/38410_2.png) [@Izzion](https://meta.discourse.org/u/Izzion)
#### Post date: [October 27, 2015, 8:19pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290/2 "2015-10-27T20:19:16Z")

</div>

We have also seen on the WTDWTF install (running 1.5.0b2) that @username\_ mentions don’t mention properly, either resulting in the name not getting formatted as a mention, or the name formatting as a mention, but clicking on the @mention does not bring up a user card, unless you click specifically on the underscore (any other section of the mention is “dead” to click on).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [October 27, 2015, 11:11pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290/3 "2015-10-27T23:11:55Z")

</div>

We should resolve this issue @eviltrout either by disallowing trailing \_ or otherwise.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 27, 2015, 11:35pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290/4 "2015-10-27T23:35:05Z")

</div>

Ideally we can some how centralize the logic

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [November 10, 2015, 8:25pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290/5 "2015-11-10T20:25:42Z")

</div>

Fixed here:

[https://github.com/discourse/discourse/commit/8eee0cf0cabed537107d0b3f896c35a6f062b174](https://github.com/discourse/discourse/commit/8eee0cf0cabed537107d0b3f896c35a6f062b174)

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [November 10, 2015, 8:25pm UTC](https://meta.discourse.org/t/mentiong-usernames-with-trailing-underscore-does-not-work/34290/6 "2015-11-10T20:25:46Z")

</div>


