diff options
Diffstat (limited to 'src/server_events.c')
-rw-r--r-- | src/server_events.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/server_events.c b/src/server_events.c index 79cc0e26..bd63de82 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -32,6 +32,7 @@ #ifdef HAVE_LIBOTR #include "otr/otr.h" +#include <libotr/proto.h> #endif #include "ui/ui.h" @@ -206,7 +207,28 @@ handle_incoming_message(char *from, char *message, gboolean priv) #ifdef HAVE_LIBOTR gboolean was_decrypted = FALSE; char *newmessage; - if (!priv) { + + if (!priv) { + //check for OTR whitespace (opportunistic or always) + char *policy = prefs_get_string(PREF_OTR_POLICY); + if (strcmp(policy, "opportunistic") == 0 || strcmp(policy, "always") == 0) { + char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE); + if (whitespace_base) { + if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) { + // Remove whitespace pattern for proper display in UI + // Handle both BASE+TAGV1/2(16+8) and BASE+TAGV1+TAGV2(16+8+8) + int tag_length = 24; + if (strstr(message, OTRL_MESSAGE_TAG_V2) && strstr(message, OTRL_MESSAGE_TAG_V1)) { + tag_length = 32; + } + memmove(whitespace_base, whitespace_base+tag_length, tag_length); + log_debug("<%s>", message); + char *otr_query_message = otr_start_query(); + cons_show("OTR Whitespace pattern detected. Attempting to start OTR session..."); + message_send(otr_query_message, from); + } + } + } newmessage = otr_decrypt_message(from, message, &was_decrypted); // internal OTR message |