core: AutoWhoX, only search nickname by nickname
authorShane Synan <digitalcircuit36939@gmail.com>
Thu, 13 Sep 2018 07:00:17 +0000 (02:00 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 13 Sep 2018 21:46:02 +0000 (23:46 +0200)
When running automatic WhoX, explicitly specify "n" to search by
nickname only.  Don't rely on server defaults.  This fixes an issue
with Quassel's autoWHO causing noise in the Status Buffer uncovered
by InspIRCd 3.0's implementation of WhoX that follows the spec.

Fix up incorrect attempt to escape "%" as "%%".  Apparently,
QString::arg() doesn't need to escape this.

Before: WHO <nickname> %%chtsunfra,<unique_number>
After:  WHO <nickname> n%chtsunfra,<unique_number>

See https://github.com/quakenet/snircd/blob/master/doc/readme.who
And https://doc.qt.io/qt-5/qstring.html#arg

Thanks to @genius3000 for reporting and tracking down this issue!

Fixes #1487

src/core/corenetwork.cpp

index 06c769c..fcafde4 100644 (file)
@@ -1375,11 +1375,23 @@ void CoreNetwork::sendAutoWho()
         }
         if (supports("WHOX")) {
             // Use WHO extended to poll away users and/or user accounts
+            // Explicitly only match on nickname ("n"), don't rely on server defaults
+            //
+            // WHO <nickname> n%chtsunfra,<unique_number>
+            //
             // See http://faerion.sourceforge.net/doc/irc/whox.var
-            // And https://github.com/hexchat/hexchat/blob/c874a9525c9b66f1d5ddcf6c4107d046eba7e2c5/src/common/proto-irc.c#L750
-            putRawLine(serverEncode(QString("WHO %1 %%chtsunfra,%2")
-                                    .arg(serverEncode(chanOrNick), QString::number(IrcCap::ACCOUNT_NOTIFY_WHOX_NUM))));
+            // And https://github.com/quakenet/snircd/blob/master/doc/readme.who
+            // And https://github.com/hexchat/hexchat/blob/57478b65758e6b697b1d82ce21075e74aa475efc/src/common/proto-irc.c#L752
+            putRawLine(serverEncode(QString("WHO %1 n%chtsunfra,%2")
+                                    .arg(serverEncode(chanOrNick),
+                                         QString::number(IrcCap::ACCOUNT_NOTIFY_WHOX_NUM))));
         } else {
+            // Fall back to normal WHO
+            //
+            // Note: According to RFC 1459, "WHO <phrase>" can fall back to searching realname,
+            // hostmask, etc.  There's nothing we can do about that :(
+            //
+            // See https://tools.ietf.org/html/rfc1459#section-4.5.1
             putRawLine(serverEncode(QString("WHO %1").arg(chanOrNick)));
         }
         break;