RocketChat / RocketChat/EmbeddedChat
Fix: Username validation regex missing anchors
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
Description:
The current username validation regex /[0-9a-zA-Z-_.]+/ in EmbeddedChatApi.ts lacks start (^) and end ($) anchors. This causes the validation to pass for any string that contains at least one valid character, even if the rest of the string is invalid.
Steps to reproduce:
- Call
updateUserUsername(userid, "@#$a@#$"). - Observe that
usernameRegExp.test(newUserName)returnstruebecause it matches the character "a". - The method proceeds to attempt an update with an invalid username format.
Expected behavior:
The validation should fail if the string contains any characters outside the allowed set [0-9a-zA-Z-_.].
Actual behavior:
The validation passes if at least one character in the string matches the regex.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in EmbeddedChatApi.ts and inspect the usernameRegExp check used by updateUserUsername. Reproduce the issue with "@#$a@#$" and verify that usernames containing characters outside the allowed set fail validation while valid usernames continue to pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100