summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2020-08-16 16:05:15 +0200
committerlouiz’ <louiz@louiz.org>2020-08-16 16:05:15 +0200
commitb98434b5d04d1ada9b24475e17ee8947d96ad1e3 (patch)
treee0f4fe2959c8bc9e406b2157acf8f02df7e9f8bd /src/irc
parentdf2fe0bc4bf6240e47abf26ff88ffdfc9373f481 (diff)
downloadbiboumi-b98434b5d04d1ada9b24475e17ee8947d96ad1e3.tar.gz
biboumi-b98434b5d04d1ada9b24475e17ee8947d96ad1e3.tar.bz2
biboumi-b98434b5d04d1ada9b24475e17ee8947d96ad1e3.tar.xz
biboumi-b98434b5d04d1ada9b24475e17ee8947d96ad1e3.zip
In CAP messages, handle the last arg as a list of capabilities
Instead of just one. This fixes the issue of the "trailing whitespace" since we now split it on ' ' Fix #3442
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/irc_client.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 3ae5ac6..5f0d9b9 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -1340,19 +1340,22 @@ long int IrcClient::get_throttle_limit() const
void IrcClient::on_cap(const IrcMessage &message)
{
const auto& sub_command = message.arguments[1];
- const auto& cap = message.arguments[2];
- auto it = this->capabilities.find(cap);
- if (it == this->capabilities.end())
+ const auto& caps = utils::split(message.arguments[2], ' ', false);
+ for (const auto& cap: caps)
{
- log_warning("Received a CAP message for something we didn’t ask, or that we already handled.");
- return;
+ auto it = this->capabilities.find(cap);
+ if (it == this->capabilities.end())
+ {
+ log_warning("Received a CAP message for something we didn’t ask, or that we already handled: [", cap, "]");
+ return;
+ }
+ Capability& capability = it->second;
+ if (sub_command == "ACK")
+ capability.on_ack();
+ else if (sub_command == "NACK")
+ capability.on_nack();
+ this->capabilities.erase(it);
}
- Capability& capability = it->second;
- if (sub_command == "ACK")
- capability.on_ack();
- else if (sub_command == "NACK")
- capability.on_nack();
- this->capabilities.erase(it);
if (this->capabilities.empty())
this->cap_end();
}