X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcoresessioneventprocessor.cpp;h=ee66717e7efb7dd608863058a0709ec95c90e7e2;hb=156f88b0a12dd2fb65a78c3ce088ce6ba57feafe;hp=a89020c006bdfe0006ff1144e5288ed323322527;hpb=815f878218872c630f0b054aee40f524cad8f1a8;p=quassel.git diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index a89020c0..ee66717e 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -174,15 +174,25 @@ void CoreSessionEventProcessor::processIrcEventCap(IrcEvent *e) capListFinished = true; availableCaps = e->params().at(2).split(' '); } + // Sort capabilities before requesting for consistency among networks. This may avoid + // unexpected cases when some networks offer capabilities in a different order than + // others. It also looks nicer in logs. Not required. + availableCaps.sort(); // Store what capabilities are available - QStringList availableCapPair; + QString availableCapName, availableCapValue; for (int i = 0; i < availableCaps.count(); ++i) { // Capability may include values, e.g. CAP * LS :multi-prefix sasl=EXTERNAL - availableCapPair = availableCaps[i].trimmed().split('='); - if(availableCapPair.count() >= 2) { - coreNet->addCap(availableCapPair.at(0).trimmed().toLower(), availableCapPair.at(1).trimmed()); - } else { - coreNet->addCap(availableCapPair.at(0).trimmed().toLower()); + // Capability name comes before the first '='. If no '=' exists, this gets the + // whole string instead. + availableCapName = availableCaps[i].section('=', 0, 0).trimmed(); + // Some capabilities include multiple key=value pairs in the listing, + // e.g. "sts=duration=31536000,port=6697" + // Include everything after the first equal sign as part of the value. If no '=' + // exists, this gets an empty string. + availableCapValue = availableCaps[i].section('=', 1).trimmed(); + // Only add the capability if it's non-empty + if (!availableCapName.isEmpty()) { + coreNet->addCap(availableCapName, availableCapValue); } }