From a9c005dc7e3ab74b00d3c161be3dee52584002bf Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Mon, 11 Jul 2016 07:04:54 -0400 Subject: [PATCH] Try to recover from some bad CAP replies, docs Modify CAP ACK and CAP NAK commands to try to continue when possible rather than getting stuck. Fix related documentation. --- src/core/coresessioneventprocessor.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index 7e6a5f4a..5b639b7b 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -212,8 +212,11 @@ void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e) coreNet->beginCapNegotiation(); } else if (capCommand == "ACK") { // CAP ACK requires at least 3 parameters (no empty response allowed) - if (!checkParamCount(e, 3)) + if (!checkParamCount(e, 3)) { + // If an invalid reply is sent, try to continue rather than getting stuck. + coreNet->sendNextCap(); return; + } // Server: CAP * ACK :multi-prefix sasl // Got the capability we want, handle as needed. @@ -231,8 +234,14 @@ void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e) } } else if (capCommand == "NAK" || capCommand == "DEL") { // CAP NAK/DEL require at least 3 parameters (no empty response allowed) - if (!checkParamCount(e, 3)) + if (!checkParamCount(e, 3)) { + if (capCommand == "NAK") { + // If an invalid reply is sent, try to continue rather than getting stuck. This + // only matters for denied caps, not removed caps. + coreNet->sendNextCap(); + } return; + } // Either something went wrong with this capability, or it is no longer supported // > For CAP NAK @@ -253,8 +262,8 @@ void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e) } if (capCommand == "NAK") { - // Continue negotiation when capability listing complete only if this is the result - // of a denied cap, not a removed cap + // Continue negotiation only if this is the result of a denied cap, not a removed + // cap coreNet->sendNextCap(); } } -- 2.20.1