soc.2009.telepathy: 4242313c: Escape HTML special characters from rece...

sttwister at soc.pidgin.im sttwister at soc.pidgin.im
Wed Jun 3 09:55:31 EDT 2009


-----------------------------------------------------------------
Revision: 4242313c69229c17ddb0c1f1ddc18c6693cea58f
Ancestor: aa0862e3e617246c5cd9d6fffbe9ee4cbc6ac410
Author: sttwister at soc.pidgin.im
Date: 2009-06-03T13:53:14
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/4242313c69229c17ddb0c1f1ddc18c6693cea58f

Modified files:
        libpurple/protocols/telepathy/telepathy.c

ChangeLog: 

Escape HTML special characters from received messages

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy.c	bbb46df3caae4fa5d09ca07dfcc1a492239d27a0
+++ libpurple/protocols/telepathy/telepathy.c	386b88ea4714fccbbf43ff07e65f143da4c8b877
@@ -297,16 +297,27 @@ list_pending_messages_cb  (TpChannel *pr
 			PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, data->acct);
 			PurpleConvIm *im;
 
+			/* escape HTML special characters */
+			gchar *escaped_message = g_markup_escape_text(msg, -1);
+
+			purple_debug_info("telepathy", "Escaped: %s\n", escaped_message);
+
+			/* also change \n to <br> */
+			gchar *final_message = purple_strdup_withhtml(escaped_message);
+			g_free(escaped_message);
+
 			if (conv == NULL)
 			{
 				conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, data->acct, from);
 			}
 			im = purple_conversation_get_im_data(conv);
 
-			purple_debug_info("telepathy", "Contact %s says \"%s\"\n", from, msg);
+			purple_debug_info("telepathy", "Contact %s says \"%s\" (escaped: \"%s\")\n", from, msg, final_message);
 
 			/* transmit the message to the UI */
-			purple_conv_im_write(im, from, msg, 0, timestamp);
+			purple_conv_im_write(im, from, final_message, 0, timestamp);
+
+			g_free(final_message);
 		}
 	}
 }


More information about the Commits mailing list