# HG changeset patch # User andrew.victor@mxit.com # Date 1279700622 0 # Node ID fe072dddc42cbd468ec227cfc4399e3da97144f4 # Parent bcc196eb47c2198a7867e71ea012f833aa74e0dc 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. diff -r bcc196eb47c2 -r fe072dddc42c libpurple/protocols/mxit/markup.c --- a/libpurple/protocols/mxit/markup.c Tue Jul 20 13:44:56 2010 +0000 +++ b/libpurple/protocols/mxit/markup.c Wed Jul 21 08:23:42 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, "%s: ", 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 */