diff options
-rw-r--r-- | degesch.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -2693,6 +2693,10 @@ buffer_rename (struct app_context *ctx, { hard_assert (buffer->type == BUFFER_PM); + // FIXME: this will never find anything as we are being sent + // the full buffer name, including the server name; + // searching in "buffers_by_name" won't do it either, + // we seem to need more information to properly handle this struct buffer *collision = str_map_find (&buffer->server->irc_buffer_map, new_name); if (collision) @@ -4383,9 +4387,13 @@ irc_handle_nick (struct server *s, const struct irc_message *msg) if (!user) return; - // What the fuck + bool lexicographically_identical = + !irc_server_strcmp (s, user->nickname, new_nickname); + + // What the fuck, someone renamed themselves to ourselves // TODO: probably log a message and force a reconnect - if (str_map_find (&s->irc_users, new_nickname)) + if (!lexicographically_identical + && !irc_server_strcmp (s, new_nickname, s->irc_user->nickname)) return; // Log a message in any PM buffer and rename it; @@ -4394,8 +4402,11 @@ irc_handle_nick (struct server *s, const struct irc_message *msg) str_map_find (&s->irc_buffer_map, user->nickname); if (pm_buffer) { - str_map_set (&s->irc_buffer_map, new_nickname, pm_buffer); - str_map_set (&s->irc_buffer_map, user->nickname, NULL); + if (!lexicographically_identical) + { + str_map_set (&s->irc_buffer_map, new_nickname, pm_buffer); + str_map_set (&s->irc_buffer_map, user->nickname, NULL); + } char *who = irc_is_this_us (s, msg->prefix) ? irc_to_utf8 (s->ctx, msg->prefix) @@ -4440,8 +4451,11 @@ irc_handle_nick (struct server *s, const struct irc_message *msg) } // Finally rename the user - str_map_set (&s->irc_users, new_nickname, user_ref (user)); - str_map_set (&s->irc_users, user->nickname, NULL); + if (!lexicographically_identical) + { + str_map_set (&s->irc_users, new_nickname, user_ref (user)); + str_map_set (&s->irc_users, user->nickname, NULL); + } free (user->nickname); user->nickname = xstrdup (new_nickname); |