pidgin.mxit: f076179c: If a chatroom user's nickname contains M...

andrew.victor at mxit.com andrew.victor at mxit.com
Wed Jul 28 09:56:20 EDT 2010


----------------------------------------------------------------------
Revision: f076179c710fd4a5ce523d997c91996222fda668
Parent:   82e7f1b7c8af5634ca7519af59901321eab7e8dc
Author:   andrew.victor at mxit.com
Date:     07/21/10 04:23:42
Branch:   im.pidgin.pidgin.mxit
URL: http://d.pidgin.im/viewmtn/revision/info/f076179c710fd4a5ce523d997c91996222fda668

Changelog: 

If a chatroom user's nickname contains MXit markup characters, they are escaped
by the chatroom service before being sent.  When the client extracts the nickname
field we need to perform un-escaping (ie, "\X" -> "X" ) to restore the original
nickname.


Changes against parent 82e7f1b7c8af5634ca7519af59901321eab7e8dc

  patched  libpurple/protocols/mxit/markup.c

-------------- next part --------------
============================================================
--- libpurple/protocols/mxit/markup.c	7425eff2b4c1e5c2e133fbcfaed2daff16f42444
+++ libpurple/protocols/mxit/markup.c	90c609692e713898ddc7407fe933319907091207
@@ -662,7 +662,7 @@ static int mxit_parse_vibe( struct RXMsg
  *  @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 @@ static int mxit_extract_chatroom_nick( s
 		 * 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 @@ static int mxit_extract_chatroom_nick( s
 		}
 
 		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 @@ void mxit_parse_markup( struct RXMsgData
 	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 */


More information about the Commits mailing list