From 70b923a7fcc11011e536ffb741f6158798f2fb8e Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 23 Feb 2015 23:44:34 +0000 Subject: [PATCH] Lowercase barejid in Jid --- src/jid.c | 7 +++++-- src/xmpp/roster.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) 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/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); }