Commit a8e922fc authored by louiz’'s avatar louiz’

Handle the NAMES message for an already-joined or non-existing channel

If a user manually does a NAMES query, the result were interpreted as a user
list, which is wrong. And with the special * argument, this would even cause
a crash.

Fix #3357
parent 4f6bf078
......@@ -641,6 +641,11 @@ void IrcClient::set_and_forward_user_list(const IrcMessage& message)
{
const std::string chan_name = utils::tolower(message.arguments[2]);
IrcChannel* channel = this->get_channel(chan_name);
if (channel->joined)
{
this->forward_server_message(message);
return;
}
std::vector<std::string> nicks = utils::split(message.arguments[3], ' ');
for (const std::string& nick: nicks)
{
......@@ -776,6 +781,16 @@ void IrcClient::on_channel_completely_joined(const IrcMessage& message)
{
const std::string chan_name = utils::tolower(message.arguments[1]);
IrcChannel* channel = this->get_channel(chan_name);
if (chan_name == "*" || channel->joined)
{
this->forward_server_message(message);
return;
}
if (!channel->get_self())
{
log_error("End of NAMES list but we never received our own nick.");
return;
}
channel->joined = true;
this->bridge.send_user_join(this->hostname, chan_name, channel->get_self(),
channel->get_self()->get_most_significant_mode(this->sorted_user_modes), true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment