changeset 28682:d9eb51a3a3a2

jabber: Don't try to pull a photo out of the <PHOTO/> cdata. When the data from the server looks literally like: <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL></BINVAL> </PHOTO> 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.
author Paul Aurich <paul@darkrain42.org>
date Sat, 03 Oct 2009 02:50:48 +0000
parents 53bf7fd37cb0
children 3397fb5f89cf
files libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/presence.c
diffstat 2 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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);
 		}
 	}