about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2022-07-04 17:13:31 +0200
committerGitHub <noreply@github.com>2022-07-04 17:13:31 +0200
commit6e1ac439ec179f4da3c9645518676d872b7400f5 (patch)
tree318417e5bce928f8d40e73539443495f72e313ce
parent9ef3491228f67403bfc56a756f6a96aa428df610 (diff)
parentc8b2979dcda8cca3052164ae9bfd09adbf7523fc (diff)
downloadprofani-tty-6e1ac439ec179f4da3c9645518676d872b7400f5.tar.gz
Merge pull request #1734 from profanity-im/fix/1733
Be more resilient when receiving empty messages
-rw-r--r--src/event/server_events.c8
-rw-r--r--src/ui/chatwin.c6
-rw-r--r--src/ui/mucwin.c5
-rw-r--r--src/ui/privwin.c6
4 files changed, 25 insertions, 0 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 6dae4d9f..57f73c06 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -545,6 +545,14 @@ static void
 _sv_ev_incoming_ox(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit)
 {
 #ifdef HAVE_LIBGPGME
+    if (message->plain == NULL) {
+        if (message->body == NULL) {
+            log_error("Couldn't decrypt OX message and body was empty");
+            return;
+        }
+        message->plain = strdup(message->body);
+    }
+
     //_clean_incoming_message(message);
     chatwin_incoming_msg(chatwin, message, new_win);
     log_database_add_incoming(message);
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index c7cf8ddb..32fd3553 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -310,6 +310,12 @@ void
 chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created)
 {
     assert(chatwin != NULL);
+
+    if (message->plain == NULL) {
+        log_error("chatwin_incoming_msg: Message with no plain field from: %s", message->from_jid);
+        return;
+    }
+
     char* old_plain = message->plain;
 
     message->plain = plugins_pre_chat_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain);
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index b48a4a54..3c4d7447 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -551,6 +551,11 @@ mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList
     assert(mucwin != NULL);
     int flags = 0;
 
+    if (message->plain == NULL) {
+        log_error("mucwin_incoming_msg: Message with no plain field from: %s", message->from_jid);
+        return;
+    }
+
     if (filter_reflection && message_is_sent_by_us(message, TRUE)) {
         /* Ignore reflection messages */
         return;
diff --git a/src/ui/privwin.c b/src/ui/privwin.c
index 20611ea4..b683a839 100644
--- a/src/ui/privwin.c
+++ b/src/ui/privwin.c
@@ -39,6 +39,7 @@
 #include <glib.h>
 #include <stdlib.h>
 
+#include "log.h"
 #include "config/preferences.h"
 #include "ui/win_types.h"
 #include "ui/window.h"
@@ -50,6 +51,11 @@ privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message)
 {
     assert(privatewin != NULL);
 
+    if (message->plain == NULL) {
+        log_error("privwin_incoming_msg: Message with no plain field from: %s", message->from_jid);
+        return;
+    }
+
     ProfWin* window = (ProfWin*)privatewin;
     int num = wins_get_num(window);