From b960f7a5c600af48f940a5da5b788f9254ba29d0 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Sun, 18 Feb 2024 20:14:32 +0100 Subject: [PATCH] removing non-ascii characters from messages --- src/chat/misc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/chat/misc.c b/src/chat/misc.c index da9a180..680321b 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -330,6 +330,15 @@ void why2_send_socket(char *text, char *username, int socket) //UNFUCK QUOTES FROM text_copy remove_json_syntax_characters(text_copy); + //REMOVE NON ASCII CHARS + int j = 0; + for (int i = 0; text_copy[i] != '\0'; i++) + { + if ((20 <= text_copy[i] && text_copy[i] <= 126)) text_copy[i] = text_copy[j++] = text_copy[i]; + } + + text_copy[j] = '\0'; + //ADD OBJECTS json_object_object_add(json, "message", json_object_new_string(text_copy)); if (username != NULL) json_object_object_add(json, "username", json_object_new_string(username)); //WAS SENT FROM SERVER