1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge pull request #1734 from profanity-im/fix/1733

Be more resilient when receiving empty messages
This commit is contained in:
Michael Vetter 2022-07-04 17:13:31 +02:00 committed by GitHub
commit 6e1ac439ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -545,6 +545,14 @@ static void
_sv_ev_incoming_ox(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit) _sv_ev_incoming_ox(ProfChatWin* chatwin, gboolean new_win, ProfMessage* message, gboolean logit)
{ {
#ifdef HAVE_LIBGPGME #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); //_clean_incoming_message(message);
chatwin_incoming_msg(chatwin, message, new_win); chatwin_incoming_msg(chatwin, message, new_win);
log_database_add_incoming(message); log_database_add_incoming(message);

View File

@ -310,6 +310,12 @@ void
chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created) chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created)
{ {
assert(chatwin != NULL); 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; char* old_plain = message->plain;
message->plain = plugins_pre_chat_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain); message->plain = plugins_pre_chat_message_display(message->from_jid->barejid, message->from_jid->resourcepart, message->plain);

View File

@ -551,6 +551,11 @@ mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList
assert(mucwin != NULL); assert(mucwin != NULL);
int flags = 0; 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)) { if (filter_reflection && message_is_sent_by_us(message, TRUE)) {
/* Ignore reflection messages */ /* Ignore reflection messages */
return; return;

View File

@ -39,6 +39,7 @@
#include <glib.h> #include <glib.h>
#include <stdlib.h> #include <stdlib.h>
#include "log.h"
#include "config/preferences.h" #include "config/preferences.h"
#include "ui/win_types.h" #include "ui/win_types.h"
#include "ui/window.h" #include "ui/window.h"
@ -50,6 +51,11 @@ privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message)
{ {
assert(privatewin != NULL); 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; ProfWin* window = (ProfWin*)privatewin;
int num = wins_get_num(window); int num = wins_get_num(window);