xmpp.custom_smiley: 8b901ad4: Added a workaround for receiving smileys...
malu at pidgin.im
malu at pidgin.im
Thu Sep 11 15:16:06 EDT 2008
-----------------------------------------------------------------
Revision: 8b901ad4ba6c969957644156f9786ec84de1897c
Ancestor: aa40b9ad8f9e94c4a3530669411f9e421ccbdc14
Author: malu at pidgin.im
Date: 2008-09-11T19:12:39
Branch: im.pidgin.xmpp.custom_smiley
URL: http://d.pidgin.im/viewmtn/revision/info/8b901ad4ba6c969957644156f9786ec84de1897c
Modified files:
libpurple/protocols/jabber/message.c
ChangeLog:
Added a workaround for receiving smileys from Jabbim,
which uses the "cid" string as the "alt" attribute on <img/>s
resulting in the smiley shortcut being formatted as a mailto: link.
This reformats incoming shortcuts if the are formed as email addresses.
Also, we don't need to escape the incoming text, as it is an XML attribute
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/message.c 85c8a5fc1a7c750dd2175b525235101b55a148b2
+++ libpurple/protocols/jabber/message.c cfac4f9d5fe446dde568729192dbed522113c1a2
@@ -346,7 +346,14 @@ jabber_message_get_refs_from_xmlnode_int
/* if there is no "alt" string, use the cid...
include the entire src, eg. "cid:.." to avoid linkification */
if (alt && alt[0] != '\0') {
- ref->alt = g_strdup(xmlnode_get_attrib(child, "alt"));
+ /* workaround for when "alt" is set to the value of the
+ CID (which Jabbim seems to do), to avoid it showing up
+ as an mailto: link */
+ if (purple_email_is_valid(alt)) {
+ ref->alt = g_strdup_printf("smiley:%s", alt);
+ } else {
+ ref->alt = g_strdup(alt);
+ }
} else {
ref->alt = g_strdup(src);
}
@@ -424,9 +431,15 @@ jabber_message_xml_to_string_strip_img_s
gchar *escaped = NULL;
/* if the "alt" attribute is empty, put the cid as smiley string */
if (alt && alt[0] != '\0') {
- escaped = g_markup_escape_text(alt, -1);
- out = g_string_append(out, escaped);
- g_free(escaped);
+ /* if the "alt" is the same as the CID, as Jabbim does,
+ this prevents linkification... */
+ if (purple_email_is_valid(alt)) {
+ const gchar *safe_alt = g_strdup_printf("smiley:%s", alt);
+ out = g_string_append(out, safe_alt);
+ g_free(safe_alt);
+ } else {
+ out = g_string_append(out, alt);
+ }
} else {
out = g_string_append(out, src);
}
More information about the Commits
mailing list