Skip to content

fix(api): add anchors to username validation regex#1202

Draft
sudorishabh wants to merge 1 commit intoRocketChat:developfrom
sudorishabh:fix/username-regex-bypass
Draft

fix(api): add anchors to username validation regex#1202
sudorishabh wants to merge 1 commit intoRocketChat:developfrom
sudorishabh:fix/username-regex-bypass

Conversation

@sudorishabh
Copy link

This change hardens the username validation logic in the @embeddedchat/api package. Usernames that were previously "partially" valid will now be rejected, triggering the automatic username suggestion fallback.

Fixes #1201

Changes

  • Updated packages/api/src/EmbeddedChatApi.ts:
  • Regex changed from /[0-9a-zA-Z-_.]+/ to /^[0-9a-zA-Z-_.]+$/.

Impact

  • Security/Stability: Prevents invalid usernames from being sent to the Rocket.Chat server during the update process.
  • User Experience: Users with invalid display names (which are used to generate the default username) will more reliably be assigned a suggested valid username instead of an error-prone one.

Action Items

  • No manual migration steps are required for users of the library. The change is internal to the updateUserUsername logic.

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-1201 after approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: Username validation regex missing anchors

1 participant