degesch: sanitize IRC nicknames/channel names

Don't trust the IRCd to have them in a subset of UTF-8.
This commit is contained in:
Přemysl Eric Janouch 2020-10-31 23:25:08 +01:00
parent 821ce04915
commit 3dc6ee9a5b
Signed by: p
GPG Key ID: A0420B94F92B9493

View File

@ -4497,8 +4497,9 @@ irc_get_or_make_user_buffer (struct server *s, const char *nickname)
// Open a new buffer for the user // Open a new buffer for the user
buffer = buffer_new (s->ctx->input); buffer = buffer_new (s->ctx->input);
buffer->type = BUFFER_PM; buffer->type = BUFFER_PM;
// FIXME: this probably needs to be converted to UTF-8 char *nickname_utf8 = irc_to_utf8 (nickname);
buffer->name = xstrdup_printf ("%s.%s", s->name, nickname); buffer->name = xstrdup_printf ("%s.%s", s->name, nickname_utf8);
free (nickname_utf8);
buffer->server = s; buffer->server = s;
buffer->user = user; buffer->user = user;
str_map_set (&s->irc_buffer_map, user->nickname, buffer); str_map_set (&s->irc_buffer_map, user->nickname, buffer);
@ -6645,8 +6646,9 @@ irc_handle_join (struct server *s, const struct irc_message *msg)
buffer = buffer_new (s->ctx->input); buffer = buffer_new (s->ctx->input);
buffer->type = BUFFER_CHANNEL; buffer->type = BUFFER_CHANNEL;
// FIXME: this probably needs to be converted to UTF-8 char *channel_name_utf8 = irc_to_utf8 (channel_name);
buffer->name = xstrdup_printf ("%s.%s", s->name, channel_name); buffer->name = xstrdup_printf ("%s.%s", s->name, channel_name_utf8);
free (channel_name_utf8);
buffer->server = s; buffer->server = s;
buffer->channel = channel = buffer->channel = channel =
irc_make_channel (s, xstrdup (channel_name)); irc_make_channel (s, xstrdup (channel_name));