pidgin: fb8d8417: jabber: Check for empty string when sett...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Mon Jun 27 01:30:52 EDT 2011


----------------------------------------------------------------------
Revision: fb8d8417592c55ace530f527d2440c3240235342
Parent:   33a3e1b908ecb4b95c19fca0ccc93d4eca2bb26a
Author:   darkrain42 at pidgin.im
Date:     06/27/11 01:24:53
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/fb8d8417592c55ace530f527d2440c3240235342

Changelog: 

jabber: Check for empty string when setting mood.

The xmlnode API didn't check for the empty string ("") as
node name, which leads to...broken XML.  I added those
checks to xmlnode, and fixed this occurrence in usermood.

Fixes #14342

Changes against parent 33a3e1b908ecb4b95c19fca0ccc93d4eca2bb26a

  patched  ChangeLog
  patched  libpurple/protocols/jabber/usermood.c
  patched  libpurple/xmlnode.c

-------------- next part --------------
============================================================
--- ChangeLog	a3f79ae68e1116a7d1e3fcfdb40bc88764b3333e
+++ ChangeLog	5958d409f9ee845d76b0ff4450bf95e7a43e13ad
@@ -6,6 +6,10 @@ version 2.9.1 (MM/DD/YYYY):
 	  (#5242)
 	* Better status message handling. (Tomasz Wasilczyk) (#14314)
 
+	XMPP:
+	* Do not generate malformed XML ("</>") when setting an empty mood.
+	  (#14342)
+
 version 2.9.0 (06/23/2011):
 	Pidgin:
 	* Fix a potential remote denial-of-service bug related to displaying
============================================================
--- libpurple/xmlnode.c	de636ddece37a92051bd637f38b22d44fa0769d8
+++ libpurple/xmlnode.c	62f65e9ad8e60c0016637ebe74f8d6e37dcae5c5
@@ -62,7 +62,7 @@ xmlnode_new(const char *name)
 xmlnode*
 xmlnode_new(const char *name)
 {
-	g_return_val_if_fail(name != NULL, NULL);
+	g_return_val_if_fail(name != NULL && *name != '\0', NULL);
 
 	return new_node(name, XMLNODE_TYPE_TAG);
 }
@@ -73,7 +73,7 @@ xmlnode_new_child(xmlnode *parent, const
 	xmlnode *node;
 
 	g_return_val_if_fail(parent != NULL, NULL);
-	g_return_val_if_fail(name != NULL, NULL);
+	g_return_val_if_fail(name != NULL && *name != '\0', NULL);
 
 	node = new_node(name, XMLNODE_TYPE_TAG);
 
============================================================
--- libpurple/protocols/jabber/usermood.c	4d680a1626b290bfcc6f053b372fd9a4822ce108
+++ libpurple/protocols/jabber/usermood.c	8cde198e54f822942f383ebb74f344dd36f8f4b2
@@ -177,12 +177,12 @@ void jabber_mood_set(JabberStream *js, c
 	xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/mood");
 	moodnode = xmlnode_new_child(xmlnode_new_child(publish, "item"), "mood");
 	xmlnode_set_namespace(moodnode, "http://jabber.org/protocol/mood");
-	if (mood) {
+	if (mood && *mood) {
 		/* if mood is NULL, set an empty mood node, meaning: unset mood */
 	    xmlnode_new_child(moodnode, mood);
 	}
 
-	if (text && text[0] != '\0') {
+	if (text && *text) {
 		xmlnode *textnode = xmlnode_new_child(moodnode, "text");
 		xmlnode_insert_data(textnode, text, -1);
 	}
@@ -195,4 +195,4 @@ PurpleMood *jabber_get_moods(PurpleAccou
 PurpleMood *jabber_get_moods(PurpleAccount *account)
 {
 	return moods;
-}
\ No newline at end of file
+}


More information about the Commits mailing list