changeset 30305:d3e13deb64a5

propagate from branch 'im.pidgin.pidgin' (head d198e35f28e8800ec2979cfb22965fbe0a31e10d) to branch 'im.pidgin.pidgin.mxit' (head f076179c710fd4a5ce523d997c91996222fda668)
author andrew.victor@mxit.com
date Tue, 27 Jul 2010 05:49:56 +0000
parents b6c3000eec60 (current diff) fe072dddc42c (diff)
children 6d6ac5720853
files
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/mxit/markup.c	Mon Jul 26 04:21:47 2010 +0000
+++ b/libpurple/protocols/mxit/markup.c	Tue Jul 27 05:49:56 2010 +0000
@@ -662,7 +662,7 @@
  *  @param message			The message text
  *  @return					The length of the message to skip
  */
-static int mxit_extract_chatroom_nick( struct RXMsgData* mx, char* message, int len )
+static int mxit_extract_chatroom_nick( struct RXMsgData* mx, char* message, int len, int msgflags )
 {
 	int		i;
 
@@ -673,7 +673,6 @@
 		 * Search for it....
 		 */
 		gboolean	found	= FALSE;
-		gchar*		nickname;
 
 		for ( i = 1; i < len; i++ ) {
 			if ( ( message[i] == '\n' ) && ( message[i-1] == '>' ) ) {
@@ -685,12 +684,30 @@
 		}
 
 		if ( found ) {
+			gchar*		nickname;
+
 			/*
 			 * The message definitely had an embedded nickname - generate a marked-up
 			 * message to be displayed.
 			 */
 			nickname = g_markup_escape_text( &message[1], -1 );
 
+			/* Remove any MXit escaping from nickname ("\X" --> "X") */
+			if ( msgflags & CP_MSG_MARKUP ) {
+				int	nicklen = strlen( nickname );
+				int	j, k;
+
+				for ( j = 0, k = 0; j < nicklen; j++ ) {
+					if ( nickname[j] == '\\' )
+						j++;
+
+					nickname[k] = nickname[j];
+					k++;
+				}
+
+				nickname[k] = '\0';		/* terminate string */
+			}
+
 			/* add nickname within some BOLD markup to the new converted message */
 			g_string_append_printf( mx->msg, "<b>%s:</b> ", nickname );
 
@@ -747,7 +764,7 @@
 	if ( is_mxit_chatroom_contact( mx->session, mx->from ) ) {
 		/* chatroom message, so we need to extract and skip the sender's nickname
 		 * which is embedded inside the message */
-		i = mxit_extract_chatroom_nick( mx, message, len );
+		i = mxit_extract_chatroom_nick( mx, message, len, msgflags );
 	}
 
 	/* run through the message and check for custom emoticons and markup */