summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2017-07-23 15:47:06 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-07-23 15:47:06 +0200
commitb95da03f3a5c904b0e8d479b7b632ec11b4c0c5a (patch)
treedc28119d3283a34de882399d8ea475d2e0c120b2 /src/plugins
parent3ac05843eb35ff1a969e80c8aef63c5acaf0f99a (diff)
downloadweechat-b95da03f3a5c904b0e8d479b7b632ec11b4c0c5a.zip
relay: end capability negociation if CAP REQ is received without arguments (issue #1040)
This fixes a bug with clients like Atomic which are sending "CAP REQ :".
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/relay/irc/relay-irc.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/plugins/relay/irc/relay-irc.c b/src/plugins/relay/irc/relay-irc.c
index 1a93b1162..465dc6393 100644
--- a/src/plugins/relay/irc/relay-irc.c
+++ b/src/plugins/relay/irc/relay-irc.c
@@ -1227,8 +1227,8 @@ void
relay_irc_recv_command_capab (struct t_relay_client *client,
int argc, char **argv, char **argv_eol)
{
- char str_capab[1024];
- int i, capability, server_caps, caps_ok;
+ char str_capab[1024], *ptr_cap;
+ int i, capability, server_caps, num_caps_received, caps_ok;
if (weechat_strcasecmp (argv[0], "ls") == 0)
{
@@ -1251,21 +1251,26 @@ relay_irc_recv_command_capab (struct t_relay_client *client,
else if (weechat_strcasecmp (argv[0], "req") == 0)
{
/* client is asking for one or more server capabilities */
+ num_caps_received = 0;
caps_ok = 0;
server_caps = RELAY_IRC_DATA(client, server_capabilities);
for (i = 1; i < argc; i++)
{
- capability = relay_irc_search_server_capability (
- (argv[i][0] == ':') ? argv[i] + 1 : argv[i]);
- if (capability >= 0)
+ ptr_cap = (argv[i][0] == ':') ? argv[i] + 1 : argv[i];
+ if (ptr_cap[0])
{
- caps_ok = 1;
- server_caps |= 1 << capability;
- }
- else
- {
- caps_ok = 0;
- break;
+ num_caps_received++;
+ capability = relay_irc_search_server_capability (ptr_cap);
+ if (capability >= 0)
+ {
+ caps_ok = 1;
+ server_caps |= 1 << capability;
+ }
+ else
+ {
+ caps_ok = 0;
+ break;
+ }
}
}
if (caps_ok)
@@ -1277,6 +1282,17 @@ relay_irc_recv_command_capab (struct t_relay_client *client,
(RELAY_IRC_DATA(client, nick)) ? RELAY_IRC_DATA(client, nick) : "nick",
(caps_ok) ? "ACK" : "NAK",
(argc >= 2) ? ((argv_eol[1][0] == ':') ? argv_eol[1] + 1 : argv_eol[1]) : "");
+
+ /*
+ * if the CAP REQ command is received without arguments, we consider
+ * the CAP END is received; this is a workaround for clients like
+ * Atomic which are sending "CAP REQ :" (see issue #1040)
+ */
+ if (num_caps_received == 0)
+ {
+ if (!RELAY_IRC_DATA(client, connected))
+ RELAY_IRC_DATA(client, cap_end_received) = 1;
+ }
}
else if (weechat_strcasecmp (argv[0], "end") == 0)
{