From de449bd88a20e29efac637d7085a866b202231a4 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 27 Jan 2024 17:44:39 +0100 Subject: [PATCH] created check_username function this checks for characters that are not a-Z or 0-9 --- src/chat/misc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/chat/misc.c b/src/chat/misc.c index d6d3b5d..67add7b 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -188,6 +188,21 @@ void remove_json_syntax_characters(char *text) } } +why2_bool check_username(char *username) +{ + for (unsigned long i = 0; i < strlen(username); i++) + { + if (!((username[i] >= 48 && username[i] <= 57) || + (username[i] >= 65 && username[i] <= 90) || //CHECK ONLY FOR a-Z & 0-9 + (username[i] >= 97 && username[i] <= 122))) + { + return 0; + } + } + + return 1; +} + void *stop_oldest_thread(void *id) { sleep(WHY2_COMMUNICATION_TIME); //yk wait