From: Pekka Riikonen Date: Mon, 2 Dec 2002 15:53:27 +0000 (+0000) Subject: Fixed "@" handling in NICK_CHANGE notify to use more reliable X-Git-Tag: silc.client.0.9.10~30 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=c0cff07c69d5af7dbc126f4b03eddccfcfbb92a9;p=silc.git Fixed "@" handling in NICK_CHANGE notify to use more reliable check based on Client ID to determine whether nick really changed, or only Client ID changed. --- diff --git a/CHANGES b/CHANGES index 7cd2ef50..68e6cfca 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +Mon Dec 2 20:50:20 EET 2002 Pekka Riikonen + + * Remove 1.0 protocol backwards compat code from client + library. + + * Added more reliable check for whether nickname did change + or not, or whether only Client ID changed in NICK_CHANGE + notify. Affected file lib/silcclient/client_notify.c. + Fixes bug in '@' character handling in a nickname. + Mon Dec 2 16:28:29 EET 2002 Pekka Riikonen * Fixed wrong invite and ban list handling in server command diff --git a/TODO b/TODO index 009eebae..fa4fc4b0 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,6 @@ TODO for Irssi SILC Client 1.0 o Signed message payload handling on UI - o bugs parsing nicknames with @ in NICK_CHANGE - o Testing - See test plan: http://silcnet.org/docs/silc-client-1.0-test.pdf http://silcnet.org/docs/silc-client-1.0-test.ps diff --git a/lib/silcclient/client_notify.c b/lib/silcclient/client_notify.c index 50d5c562..52214213 100644 --- a/lib/silcclient/client_notify.c +++ b/lib/silcclient/client_notify.c @@ -597,82 +597,47 @@ void silc_client_notify_by_server(SilcClient client, if (!client_id) goto out; - /* From protocol version 1.1 we get the new nickname in notify as well, - so we don't have to resolve it. Do it the hard way if server doesn't - send it to us. */ + /* Take the nickname */ tmp = silc_argument_get_arg_type(args, 3, NULL); - if (tmp) { - /* Protocol version 1.1 */ - char *tmp_nick = NULL; - - /* Check whether nickname changed at all. It is possible that nick - change notify is received but nickname didn't changed, only the - ID changes. */ - if (client->internal->params->nickname_parse) - client->internal->params->nickname_parse(client_entry->nickname, - &tmp_nick); - else - tmp_nick = strdup(tmp); - - if (tmp_nick && !strcmp(tmp, tmp_nick)) { - /* Nickname didn't change. Update only the ID */ - silc_idcache_del_by_context(conn->internal->client_cache, - client_entry); - silc_free(client_entry->id); - client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT); - silc_idcache_add(conn->internal->client_cache, strdup(tmp), - client_entry->id, client_entry, 0, NULL); - - /* Notify application */ - client->internal->ops->notify(client, conn, type, - client_entry, client_entry); - break; - } - silc_free(tmp_nick); - - /* Create new client entry, and save all old information with the - new nickname and client ID */ - client_entry2 = silc_client_add_client(client, conn, NULL, NULL, - client_entry->realname, - silc_id_dup(client_id, - SILC_ID_CLIENT), 0); - if (!client_entry2) - goto out; - - if (client_entry->server) - client_entry2->server = strdup(client_entry->server); - if (client_entry->username) - client_entry2->username = strdup(client_entry->username); - if (client_entry->hostname) - client_entry2->hostname = strdup(client_entry->hostname); - silc_client_update_client(client, conn, client_entry2, tmp, NULL, NULL, - client_entry->mode); - } else { - /* Protocol version 1.0 */ + if (!tmp) + goto out; - /* Find client entry and if not found resolve it */ - client_entry2 = silc_client_get_client_by_id(client, conn, client_id); - if (!client_entry2) { - /* Resolve the entry information */ - silc_client_notify_by_server_resolve(client, conn, packet, - SILC_ID_CLIENT, client_id); + /* Check whether nickname changed at all. It is possible that nick + change notify is received but nickname didn't changed, only the + ID changes. Check whether the hashes in the Client ID match, if + they do nickname didn't change. */ + if (SILC_ID_COMPARE_HASH(client_entry->id, client_id)) { + /* Nickname didn't change. Update only the ID */ + silc_idcache_del_by_context(conn->internal->client_cache, + client_entry); + silc_free(client_entry->id); + client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT); + silc_idcache_add(conn->internal->client_cache, strdup(tmp), + client_entry->id, client_entry, 0, NULL); + + /* Notify application */ + client->internal->ops->notify(client, conn, type, + client_entry, client_entry); + break; + } - /* Add the new entry even though we resolved it. This is because we - want to replace the old entry with the new entry here right now. */ - client_entry2 = - silc_client_add_client(client, conn, NULL, NULL, NULL, - silc_id_dup(client_id, SILC_ID_CLIENT), - client_entry->mode); - - /* Replace old ID entry with new one on all channels. */ - silc_client_replace_from_channels(client, conn, client_entry, - client_entry2); - break; - } + /* Create new client entry, and save all old information with the + new nickname and client ID */ + client_entry2 = silc_client_add_client(client, conn, NULL, NULL, + client_entry->realname, + silc_id_dup(client_id, + SILC_ID_CLIENT), 0); + if (!client_entry2) + goto out; - if (client_entry2 != conn->local_entry) - silc_client_nickname_format(client, conn, client_entry2); - } + if (client_entry->server) + client_entry2->server = strdup(client_entry->server); + if (client_entry->username) + client_entry2->username = strdup(client_entry->username); + if (client_entry->hostname) + client_entry2->hostname = strdup(client_entry->hostname); + silc_client_update_client(client, conn, client_entry2, tmp, NULL, NULL, + client_entry->mode); /* Remove the old from cache */ silc_idcache_del_by_context(conn->internal->client_cache, client_entry);