From 2121ec6786d70362a3a8606c0807606f59b9b0e9 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sat, 27 Jan 2024 18:40:12 +0100 Subject: [PATCH] checking for anon & server username blocking them also --- src/chat/misc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/chat/misc.c b/src/chat/misc.c index ebf3fff..fa372b3 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -21,6 +21,7 @@ along with this program. If not, see . #include #include #include +#include #include #include @@ -189,8 +190,31 @@ void remove_json_syntax_characters(char *text) } } +void lowercase(char *string) +{ + for (unsigned long i = 0; i < strlen(string); i++) + { + string[i] = tolower(string[i]); + } +} + +why2_bool username_equal(char *u1, char *u2) +{ + char *one = why2_strdup(u1); + char *two = why2_strdup(u2); + + //LOWERCASE + lowercase(one); + lowercase(two); + + return strcmp(one, two) == 0; +} + why2_bool check_username(char *username) { + if (username_equal(username, WHY2_CHAT_SERVER_USERNAME)) return 0; //DISABLE 'server' USERNAME + if (username_equal(username, WHY2_DEFAULT_USERNAME)) return 0; //DISABLE 'anon' USERNAME DUE TO ONE USERNAME PER SERVER + for (unsigned long i = 0; i < strlen(username); i++) { if (!((username[i] >= 48 && username[i] <= 57) ||