summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-21 22:30:59 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-21 23:38:22 +0200
commit1e04fc24a7b2b23a9913011c92629c47e58a6735 (patch)
treea9fc2bad10d4694b84bc8f8d92c5fc4e49ded946 /degesch.c
parente85c98f31588f2a8a5ad0aebf0e6e4840b8f3441 (diff)
downloadxK-1e04fc24a7b2b23a9913011c92629c47e58a6735.tar.gz
xK-1e04fc24a7b2b23a9913011c92629c47e58a6735.tar.xz
xK-1e04fc24a7b2b23a9913011c92629c47e58a6735.zip
degesch: fix /nick handling
When the new nickname was lexicographically identical (for example User -> uSer), the whole thing broke down. In addition to that, we used to check if the new nickname exists and failed in that case. It _can_, however, exist. It just mustn't be us.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/degesch.c b/degesch.c
index 75ad5af..5268777 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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);