about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/mucwin.c22
-rw-r--r--src/xmpp/message.c4
2 files changed, 18 insertions, 8 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index bd67b53f..54778acb 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -389,26 +389,36 @@ _mucwin_print_mention(ProfWin* window, const char* const message, const char* co
     while (curr) {
         pos = GPOINTER_TO_INT(curr->data);
 
-        char* before_str = g_strndup(message + last_pos, pos - last_pos);
+        char *before_str = g_utf8_substring(message, last_pos, last_pos + pos - last_pos);
+
         if (strncmp(before_str, "/me ", 4) == 0) {
             win_print_them(window, THEME_ROOMMENTION, ch, flags, "");
             win_append_highlight(window, THEME_ROOMMENTION, "*%s ", from);
             win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str + 4);
         } else {
-            win_print_them(window, THEME_ROOMMENTION, ch, flags, from);
+            // print time and nick only once at beginning of the line
+            if (last_pos == 0) {
+                win_print_them(window, THEME_ROOMMENTION, ch, flags, from);
+            }
             win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str);
         }
         g_free(before_str);
-        char* mynick_str = g_strndup(message + pos, strlen(mynick));
+
+        glong mynick_len = g_utf8_strlen(mynick, -1);
+        char* mynick_str = g_utf8_substring(message, pos, pos + mynick_len);
         win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", mynick_str);
         g_free(mynick_str);
 
-        last_pos = pos + strlen(mynick);
+        last_pos = pos + mynick_len;
 
         curr = g_slist_next(curr);
     }
-    if (last_pos < strlen(message)) {
-        win_appendln_highlight(window, THEME_ROOMMENTION, "%s", &message[last_pos]);
+
+    glong message_len = g_utf8_strlen(message, -1);
+    if (last_pos < message_len) {
+        char* rest = g_utf8_substring(message, last_pos, last_pos + message_len);
+        win_appendln_highlight(window, THEME_ROOMMENTION, "%s", rest);
+        g_free(rest);
     } else {
         win_appendln_highlight(window, THEME_ROOMMENTION, "");
     }
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index b6be52a8..fc841ae2 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1086,7 +1086,7 @@ _handle_groupchat(xmpp_stanza_t* const stanza)
 #endif
 
     if (!message->plain && !message->body) {
-        log_error("Message received without body for room: %s", from_jid->str);
+        log_info("Message received without body for room: %s", from_jid->str);
         goto out;
     } else if (!message->plain) {
         message->plain = strdup(message->body);
@@ -1244,7 +1244,7 @@ _handle_muc_private_message(xmpp_stanza_t* const stanza)
     message->body = xmpp_message_get_body(stanza);
 
     if (!message->plain && !message->body) {
-        log_error("Message received without body from: %s", message->from_jid->str);
+        log_info("Message received without body from: %s", message->from_jid->str);
         goto out;
     } else if (!message->plain) {
         message->plain = strdup(message->body);