about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorlightb <lightb@bigfoot>2014-04-22 16:55:28 -0400
committerlightb <lightb@bigfoot>2014-04-22 16:55:28 -0400
commit1192e67cf76ba953031f420e5ac790989a81530c (patch)
treea0849b757b461459399faaa28abe667be93eb870 /src
parent1bd617d38936dae2f36e51ad0f28c325f57868f6 (diff)
downloadprofani-tty-1192e67cf76ba953031f420e5ac790989a81530c.tar.gz
Strip whitespace from otr tagged message for proper display.
Will handle BASE + OTRV1TAG/OTRV2TAG or BASE + OTRV1TAG + OTRV2TAG
or BASE + OTRV2TAG + OTRV1TAG
Diffstat (limited to 'src')
-rw-r--r--src/server_events.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/server_events.c b/src/server_events.c
index 29cdfbc5..3935bfbc 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -213,8 +213,15 @@ handle_incoming_message(char *from, char *message, gboolean 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) {
-	if (strstr(message,OTRL_MESSAGE_TAG_BASE)) {
+	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);