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
This commit is contained in:
+14
-11
@@ -1340,19 +1340,22 @@ long int IrcClient::get_throttle_limit() const
|
|||||||
void IrcClient::on_cap(const IrcMessage &message)
|
void IrcClient::on_cap(const IrcMessage &message)
|
||||||
{
|
{
|
||||||
const auto& sub_command = message.arguments[1];
|
const auto& sub_command = message.arguments[1];
|
||||||
const auto& cap = message.arguments[2];
|
const auto& caps = utils::split(message.arguments[2], ' ', false);
|
||||||
auto it = this->capabilities.find(cap);
|
for (const auto& cap: caps)
|
||||||
if (it == this->capabilities.end())
|
|
||||||
{
|
{
|
||||||
log_warning("Received a CAP message for something we didn’t ask, or that we already handled.");
|
auto it = this->capabilities.find(cap);
|
||||||
return;
|
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())
|
if (this->capabilities.empty())
|
||||||
this->cap_end();
|
this->cap_end();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ TEST_CASE("String split")
|
|||||||
CHECK(splitted.size() == 2);
|
CHECK(splitted.size() == 2);
|
||||||
CHECK(splitted[0] == "");
|
CHECK(splitted[0] == "");
|
||||||
CHECK(splitted[1] == "a");
|
CHECK(splitted[1] == "a");
|
||||||
|
splitted = utils::split("multi-prefix ", ' ');
|
||||||
|
CHECK(splitted[0] == "multi-prefix");
|
||||||
|
CHECK(splitted.size() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("tolower")
|
TEST_CASE("tolower")
|
||||||
|
|||||||
Reference in New Issue
Block a user