about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-10-02 22:12:41 +0100
committerJames Booth <boothj5@gmail.com>2014-10-02 22:12:41 +0100
commit1423ee7a75a494e57dded274296bec11e58eeb92 (patch)
tree03df36537ae7c598088aeb42ff1747c2fdd99986 /src/xmpp
parentbdad22e548cee6be0ad59e8e73295fdee754be31 (diff)
downloadprofani-tty-1423ee7a75a494e57dded274296bec11e58eeb92.tar.gz
Handle roster set and result when item name is empty string
fixed #431
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/roster.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index 63729e7c..5f9fa6f9 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -245,6 +245,11 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
     const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
 
+    // do not set nickname to empty string, set to NULL instead
+    if (name && (strlen(name) == 0)) {
+        name = NULL;
+    }
+
     // remove from roster
     if (g_strcmp0(sub, "remove") == 0) {
         // remove barejid and name
@@ -290,17 +295,18 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
     // handle initial roster response
     if (g_strcmp0(id, "roster") == 0) {
-        xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza,
-            STANZA_NAME_QUERY);
+        xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
         xmpp_stanza_t *item = xmpp_stanza_get_children(query);
 
         while (item != NULL) {
-            const char *barejid =
-                xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
-            const char *name =
-                xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
-            const char *sub =
-                xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
+            const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+            const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
+            const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
+
+            // do not set nickname to empty string, set to NULL instead
+            if (name && (strlen(name) == 0)) {
+                name = NULL;
+            }
 
             gboolean pending_out = FALSE;
             const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
@@ -319,8 +325,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
             item = xmpp_stanza_get_next(item);
         }
 
-        resource_presence_t conn_presence =
-            accounts_get_login_presence(jabber_get_account_name());
+        resource_presence_t conn_presence = accounts_get_login_presence(jabber_get_account_name());
         presence_update(conn_presence, NULL, 0);
     }