diff --git a/src/jid.c b/src/jid.c index d1c25ddb..e314b2cf 100644 --- a/src/jid.c +++ b/src/jid.c @@ -88,11 +88,12 @@ jid_create(const gchar * const str) if (slashp != NULL) { result->resourcepart = g_strdup(slashp + 1); result->domainpart = g_utf8_substring(domain_start, 0, g_utf8_pointer_to_offset(domain_start, slashp)); - result->barejid = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp)); + char *barejidraw = g_utf8_substring(trimmed, 0, g_utf8_pointer_to_offset(trimmed, slashp)); + result->barejid = g_utf8_strdown(barejidraw, -1); result->fulljid = g_strdup(trimmed); } else { result->domainpart = g_strdup(domain_start); - result->barejid = g_strdup(trimmed); + result->barejid = g_utf8_strdown(trimmed, -1); } if (result->domainpart == NULL) { @@ -144,7 +145,9 @@ jid_is_valid_room_form(Jid *jid) char * create_fulljid(const char * const barejid, const char * const resource) { + gchar *barejidlower = g_utf8_strdown(barejid, -1); GString *full_jid = g_string_new(barejid); + g_free(barejidlower); g_string_append(full_jid, "/"); g_string_append(full_jid, resource); diff --git a/src/roster_list.c b/src/roster_list.c index b9a142cb..ad1864f1 100644 --- a/src/roster_list.c +++ b/src/roster_list.c @@ -91,7 +91,7 @@ roster_update_presence(const char * const barejid, Resource *resource, assert(barejid != NULL); assert(resource != NULL); - PContact contact = g_hash_table_lookup(contacts, barejid); + PContact contact = roster_get_contact(barejid); if (contact == NULL) { return FALSE; } @@ -109,14 +109,18 @@ roster_update_presence(const char * const barejid, Resource *resource, PContact roster_get_contact(const char * const barejid) { - return g_hash_table_lookup(contacts, barejid); + gchar *barejidlower = g_utf8_strdown(barejid, -1); + PContact contact = g_hash_table_lookup(contacts, barejidlower); + g_free(barejidlower); + + return contact; } gboolean roster_contact_offline(const char * const barejid, const char * const resource, const char * const status) { - PContact contact = g_hash_table_lookup(contacts, barejid); + PContact contact = roster_get_contact(barejid); if (contact == NULL) { return FALSE; @@ -212,7 +216,7 @@ void roster_update(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out) { - PContact contact = g_hash_table_lookup(contacts, barejid); + PContact contact = roster_get_contact(barejid); assert(contact != NULL); p_contact_set_subscription(contact, subscription); @@ -239,7 +243,7 @@ gboolean roster_add(const char * const barejid, const char * const name, GSList *groups, const char * const subscription, gboolean pending_out) { - PContact contact = g_hash_table_lookup(contacts, barejid); + PContact contact = roster_get_contact(barejid); if (contact != NULL) { return FALSE; } diff --git a/src/xmpp/roster.c b/src/xmpp/roster.c index 1e943fb6..6de370aa 100644 --- a/src/xmpp/roster.c +++ b/src/xmpp/roster.c @@ -285,6 +285,8 @@ _roster_set_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, } } + g_free(barejid_lower); + return 1; } @@ -324,6 +326,7 @@ _roster_result_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, log_warning("Attempt to add contact twice: %s", barejid_lower); } + g_free(barejid_lower); item = xmpp_stanza_get_next(item); }