Remove unicode control characters from username

This commit is contained in:
Nanobyte 2021-04-19 03:14:31 +02:00
parent dad4fbca75
commit 3a60b6fff7

View file

@ -21,6 +21,10 @@ export async function setUsername(req: Request, res: Response) {
res.sendStatus(200);
return;
}
// remove unicode control characters from username (example: \n, \r, \t etc.)
// source: https://en.wikipedia.org/wiki/Control_character#In_Unicode
userName = userName.replace(/[\u0000-\u001F\u007F-\u009F]/g, '');
if (adminUserIDInput != undefined) {
//this is the admin controlling the other users account, don't hash the controling account's ID