Mercurial > pidgin.yaz
changeset 32178:979bab4c3bca
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
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 27 Jun 2011 05:24:53 +0000 |
parents | e0856c50cdd8 |
children | 6001935e8c62 |
files | ChangeLog libpurple/protocols/jabber/usermood.c libpurple/xmlnode.c |
diffstat | 3 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jun 26 20:37:03 2011 +0000 +++ b/ChangeLog Mon Jun 27 05:24:53 2011 +0000 @@ -6,6 +6,10 @@ (#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
--- a/libpurple/protocols/jabber/usermood.c Sun Jun 26 20:37:03 2011 +0000 +++ b/libpurple/protocols/jabber/usermood.c Mon Jun 27 05:24:53 2011 +0000 @@ -177,12 +177,12 @@ 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(PurpleAccount *account) { return moods; -} \ No newline at end of file +}
--- a/libpurple/xmlnode.c Sun Jun 26 20:37:03 2011 +0000 +++ b/libpurple/xmlnode.c Mon Jun 27 05:24:53 2011 +0000 @@ -62,7 +62,7 @@ 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 *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);