about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-23 23:12:44 +0000
committerJames Booth <boothj5@gmail.com>2015-02-23 23:12:44 +0000
commita2a187892b7bb0a343b8bbe3c46dee051d534bde (patch)
treef06bcaeb988859215e0fa01394735e7449122c59 /src
parent2f4d66ea6e8b735678fc6946ca34864275b390e4 (diff)
downloadprofani-tty-a2a187892b7bb0a343b8bbe3c46dee051d534bde.tar.gz
Lowercase barejid before adding to roster
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/roster.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c
index e6f4c2ca..1e943fb6 100644
--- a/src/xmpp/roster.c
+++ b/src/xmpp/roster.c
@@ -241,6 +241,7 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     jid_destroy(my_jid);
 
     const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+    gchar *barejid_lower = g_utf8_strdown(barejid, -1);
     const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
     const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
     const char *ask = xmpp_stanza_get_attribute(item, STANZA_ATTR_ASK);
@@ -254,12 +255,12 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
     if (g_strcmp0(sub, "remove") == 0) {
         // remove barejid and name
         if (name == NULL) {
-            name = barejid;
+            name = barejid_lower;
         }
 
-        roster_remove(name, barejid);
+        roster_remove(name, barejid_lower);
 
-        handle_roster_remove(barejid);
+        handle_roster_remove(barejid_lower);
 
     // otherwise update local roster
     } else {
@@ -273,14 +274,14 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
         GSList *groups = _get_groups_from_item(item);
 
         // update the local roster
-        PContact contact = roster_get_contact(barejid);
+        PContact contact = roster_get_contact(barejid_lower);
         if (contact == NULL) {
-            gboolean added = roster_add(barejid, name, groups, sub, pending_out);
+            gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
             if (added) {
-                handle_roster_add(barejid, name);
+                handle_roster_add(barejid_lower, name);
             }
         } else {
-            handle_roster_update(barejid, name, groups, sub, pending_out);
+            handle_roster_update(barejid_lower, name, groups, sub, pending_out);
         }
     }
 
@@ -300,6 +301,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
         while (item != NULL) {
             const char *barejid = xmpp_stanza_get_attribute(item, STANZA_ATTR_JID);
+            gchar *barejid_lower = g_utf8_strdown(barejid, -1);
             const char *name = xmpp_stanza_get_attribute(item, STANZA_ATTR_NAME);
             const char *sub = xmpp_stanza_get_attribute(item, STANZA_ATTR_SUBSCRIPTION);
 
@@ -316,10 +318,10 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
 
             GSList *groups = _get_groups_from_item(item);
 
-            gboolean added = roster_add(barejid, name, groups, sub, pending_out);
+            gboolean added = roster_add(barejid_lower, name, groups, sub, pending_out);
 
             if (!added) {
-                log_warning("Attempt to add contact twice: %s", barejid);
+                log_warning("Attempt to add contact twice: %s", barejid_lower);
             }
 
             item = xmpp_stanza_get_next(item);