Sentence-ending period is included in user and channel mentions ("thanks @john." mentions "john.")

Open
#43,391 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@mayank609 is already working on this.

Since Oct 31, 2026.

  • #43392 by @mayank609 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript

Research direction

The issue points to UserMentionDirect, ChannelMention, and UTF8NamesValidation in @rocket.chat/message-parser, and cites tests/mention.test.ts. Read the existing mention tests and inspect how trailing punctuation is parsed. Done means sentence-ending periods are excluded from mentions while the existing username-ending-in-period case is addressed; the issue says a fix and tests are already in a PR.

Written by the indexing model from the issue text.

Description

type: bug
Description

When a message ends a sentence with a mention, the period is parsed as part of the username or channel name.

Input Parsed mention Expected
thanks @john. john. john
see #general. general. general
@john... john... john

! and ? already work as expected (ask @john! mentions john), so only . is affected.

Since Mentions.execute builds message.mentions from the parsed message.md when it exists, the server then looks up a user named john.. As far as I can tell this means the intended user isn't added to mentions and doesn't get the mention notification or highlight.

Steps to reproduce
  1. Send thanks @<existing username>. in a room.
  2. The mention isn't rendered or notified for that user.

In @rocket.chat/message-parser:

parse('thanks @john.');
// MENTION_USER 'john.' instead of MENTION_USER 'john' + PLAIN_TEXT '.'
Cause

UserMentionDirect and ChannelMention use UTF8NamesValidation = $([-_.] / AlphaNumericChar)+, which accepts a trailing ..

Trade-off to discuss

The default UTF8_User_Names_Validation ([0-9a-zA-Z-_.]+) technically allows usernames that end in ., and tests/mention.test.ts currently expects @guilherme.gazzo. to mention guilherme.gazzo.. Dropping the trailing period would change that case. Ending a sentence with a mention seems much more common than a username ending in ., and this matches how Slack, GitHub and Discord handle it, but I'd like a maintainer's view on whether the change is acceptable.

I've opened a PR with a fix and tests.

Dominant language
TypeScript
Stars
46.5k
Forks
14.1k
Avg merge
1d 21h
Merged PRs (30d)
381

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/Rocket.Chat

All issues in RocketChat/Rocket.Chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.