feat: allow more safe characters in the username

This commit is contained in:
Himadri Bhattacharjee
2025-04-18 07:32:00 +05:30
parent aa0583d6c2
commit d9ef0f093c
2 changed files with 3 additions and 3 deletions

View File

@@ -45,8 +45,8 @@ people joining in with the respective privileges. Further, `bob@work` can join o
`h@cafe`, whose comment is tagged as `:admin` will be able to join the chat with admin privileges.
> [!NOTE]
Usernames may only contain ASCII alphanumeric characters and the `@`
symbol. All other characters will be stripped.
Usernames may only contain ASCII alphanumeric characters and the symbols `@-_.`.
All other characters will be stripped.
### Getting started

View File

@@ -10,7 +10,7 @@ use russh::keys::ssh_key::public::KeyData;
pub fn sanitize_name(s: &str) -> String {
let mut sanitized = String::with_capacity(s.len());
for c in s.chars() {
let ok = c.is_ascii_alphanumeric() || c == '@';
let ok = c.is_ascii_alphanumeric() || "@_-.".contains(c);
if !ok {
continue;
}