about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-12-13 13:42:43 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-12-13 13:42:43 +0100
commit3bb2e07c1ea86129ca1460b73e91a5c9fcc88d6c (patch)
tree968be3780830bad15056eeaaf278414d49c9f74a /src/event
parent20dc1710e8f5abed960c6579a63117261d1ac8de (diff)
downloadprofani-tty-3bb2e07c1ea86129ca1460b73e91a5c9fcc88d6c.tar.gz
Use helper function to clean incoming messages
We might want to use utf8proc or something to normalize utf8 strings
later?
Diffstat (limited to 'src/event')
-rw-r--r--src/event/server_events.c18
1 files changed, 9 insertions, 9 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);
+    if (strstr(message->plain, cut)) {
+        char **split = g_strsplit(message->plain, cut, -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);
-        free(message->plain);
-        message->plain = g_strjoinv("", split);
-        g_strfreev(split);
-    }
+static void
+_clean_incoming_message(ProfMessage *message)
+{
+    _cut(message, "\u200E");
+    _cut(message, "\u200F");
 }