/soc/2015/jgeboski/facebook: ac1d2fdaab42: facebook: escape/unes...
James Geboski <[email protected]>
| Newsgroups | gmane.comp.gnome.gaim.cvs |
|---|---|
| Message-ID | <[email protected]> |
Changeset: ac1d2fdaab42d8127c6cae14b4dc058348e7cc2f Author: James Geboski <[email protected]> Date: 2015-07-10 13:04 -0400 Branch: facebook URL: https://hg.pidgin.im/soc/2015/jgeboski/facebook/rev/ac1d2fdaab42 Description: facebook: escape/unescape HTML within messages This patch was inspired by a patch by Eion Robb for the purple2 variant of this plugin. diffstat: libpurple/protocols/facebook/facebook.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diffs (78 lines): diff --git a/libpurple/protocols/facebook/facebook.c b/libpurple/protocols/facebook/facebook.c --- a/libpurple/protocols/facebook/facebook.c +++ b/libpurple/protocols/facebook/facebook.c @@ -180,6 +180,7 @@ fb_cb_api_message(FbApi *api, GSList *ms { FbApiMessage *msg; FbData *fata = data; + gchar *html; gchar tid[FB_ID_STRMAX]; gchar uid[FB_ID_STRMAX]; gint id; @@ -194,12 +195,15 @@ fb_cb_api_message(FbApi *api, GSList *ms for (l = msgs; l != NULL; l = l->next) { msg = l->data; chat = NULL; + + html = purple_markup_escape_text(msg->text, -1); FB_ID_TO_STR(msg->uid, uid); if (msg->tid == 0) { - purple_serv_got_im(gc, uid, msg->text, + purple_serv_got_im(gc, uid, html, PURPLE_MESSAGE_RECV, time(NULL)); + g_free(html); continue; } @@ -210,8 +214,10 @@ fb_cb_api_message(FbApi *api, GSList *ms id = purple_chat_conversation_get_id(chat); purple_serv_got_chat_in(gc, id, uid, PURPLE_MESSAGE_RECV, - msg->text, time(NULL)); + html, time(NULL)); } + + g_free(html); } } @@ -557,6 +563,7 @@ fb_im_send(PurpleConnection *gc, PurpleM FbApi *api; FbData *fata; FbId uid; + gchar *sext; fata = purple_connection_get_protocol_data(gc); api = fb_data_get_api(fata); @@ -565,7 +572,9 @@ fb_im_send(PurpleConnection *gc, PurpleM uid = FB_ID_FROM_STR(name); text = purple_message_get_contents(msg); - fb_api_message(api, uid, FALSE, text); + sext = purple_markup_strip_html(text); + fb_api_message(api, uid, FALSE, sext); + g_free(sext); return 1; } @@ -691,6 +700,7 @@ fb_chat_send(PurpleConnection *gc, gint FbApi *api; FbData *fata; FbId tid; + gchar *sext; PurpleAccount *acct; PurpleChatConversation *chat; @@ -703,7 +713,9 @@ fb_chat_send(PurpleConnection *gc, gint tid = FB_ID_FROM_STR(name); text = purple_message_get_contents(msg); - fb_api_message(api, tid, TRUE, text); + sext = purple_markup_strip_html(text); + fb_api_message(api, tid, TRUE, sext); + g_free(sext); name = purple_account_get_username(acct); purple_serv_got_chat_in(gc, id, name, _______________________________________________ Commits mailing list [email protected] https://pidgin.im/cgi-bin/mailman/listinfo/commits