1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Use helper function to clean incoming messages

We might want to use utf8proc or something to normalize utf8 strings
later?
This commit is contained in:
Michael Vetter 2019-12-13 13:42:43 +01:00
parent 20dc1710e8
commit 3bb2e07c1e

View File

@ -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");
}