diff libpurple/protocols/jabber/presence.c @ 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 faf98a4b27d8
children d1c18bd588e2 f3f7f683fda5
line wrap: on
line diff
--- 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);
 		}
 	}