From 3bb2e07c1ea86129ca1460b73e91a5c9fcc88d6c Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Fri, 13 Dec 2019 13:42:43 +0100 Subject: [PATCH] Use helper function to clean incoming messages We might want to use utf8proc or something to normalize utf8 strings later? --- src/event/server_events.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/event/server_events.c b/src/event/server_events.c index 49f8fa64..40cc1240 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -1427,19 +1427,19 @@ sv_ev_bookmark_autojoin(Bookmark *bookmark) } static void -_clean_incoming_message(ProfMessage *message) +_cut(ProfMessage *message, const char *cut) { - if (strstr(message->plain, "\u200E")) { - char **split = g_strsplit(message->plain, "\u200E", -1); - free(message->plain); - message->plain = g_strjoinv("", split); - g_strfreev(split); - } - - if (strstr(message->plain, "\u200F")) { - char **split = g_strsplit(message->plain, "\u200F", -1); + if (strstr(message->plain, cut)) { + char **split = g_strsplit(message->plain, cut, -1); free(message->plain); message->plain = g_strjoinv("", split); g_strfreev(split); } } + +static void +_clean_incoming_message(ProfMessage *message) +{ + _cut(message, "\u200E"); + _cut(message, "\u200F"); +}