# HG changeset patch # User Paul Aurich # Date 1254538248 0 # Node ID d9eb51a3a3a2a6bb6aba610b4dfbd9275fe29b42 # Parent 53bf7fd37cb05436e39252fc1838b3d5e6a48134 jabber: Don't try to pull a photo out of the cdata. When the data from the server looks literally like: image/jpeg xmlnode_get_data(photo_node) will contain (whitespace) data, but in no way is it a base64-encoded image. I can't find any reference to clients distributing avatars in that way in the XEP or the RFC. diff -r 53bf7fd37cb0 -r d9eb51a3a3a2 libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Fri Oct 02 16:19:19 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Sat Oct 03 02:50:48 2009 +0000 @@ -1149,9 +1149,8 @@ char *bintext = NULL; xmlnode *binval; - if( ((binval = xmlnode_get_child(child, "BINVAL")) && - (bintext = xmlnode_get_data(binval))) || - (bintext = xmlnode_get_data(child))) { + if ((binval = xmlnode_get_child(child, "BINVAL")) && + (bintext = xmlnode_get_data(binval))) { gsize size; guchar *data; gboolean photo = (strcmp(child->name, "PHOTO") == 0); diff -r 53bf7fd37cb0 -r d9eb51a3a3a2 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Fri Oct 02 16:19:19 2009 +0000 +++ b/libpurple/protocols/jabber/presence.c Sat Oct 03 02:50:48 2009 +0000 @@ -403,19 +403,20 @@ g_free(nickname); } - if((photo = xmlnode_get_child(vcard, "PHOTO")) && - (( (binval = xmlnode_get_child(photo, "BINVAL")) && - (text = xmlnode_get_data(binval))) || - (text = xmlnode_get_data(photo)))) { + if ((photo = xmlnode_get_child(vcard, "PHOTO")) && + (binval = xmlnode_get_child(photo, "BINVAL")) && + (text = xmlnode_get_data(binval))) { guchar *data; - gchar *hash; gsize size; data = purple_base64_decode(text, &size); - hash = jabber_calculate_data_sha1sum(data, size); + if (data) { + gchar *hash = jabber_calculate_data_sha1sum(data, size); + purple_buddy_icons_set_for_user(js->gc->account, from, data, + size, hash); + g_free(hash); + } - purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); - g_free(hash); g_free(text); } }