From 76f7748c8a3e1345cf4b987620aaa7fc6ca30d4e Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 16 Dec 2021 01:43:33 -0500 Subject: [PATCH] correctly account for nickname in CAP LS arithmetic The arithmetic was assuming that the nickname is * (which it is pre-registration). However, we were sending the actual nickname post-registration. It would be simpler to always send *, but it appears that the nickname is actually required by the spec: >Replies from the server must [sic] contain the client identifier name or >asterisk if one is not yet available. --- irc/handlers.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 38a88bbf..385605cd 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -527,9 +527,9 @@ func capHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response // 1. WeeChat 1.4 won't accept the CAP reply unless it contains the server.name source // 2. old versions of Kiwi and The Lounge can't parse multiline CAP LS 302 (#661), // so try as hard as possible to get the response to fit on one line. - // :server.name CAP * LS * :\r\n - // 1 [ 7 ] [4 ] [2 ] - maxLen := (MaxLineLen - 2) - 1 - len(server.name) - 7 - len(subCommand) - 4 + // :server.name CAP nickname LS * :\r\n + // 1 [5 ] 1 [4 ] [2 ] + maxLen := (MaxLineLen - 2) - 1 - len(server.name) - 5 - len(details.nick) - 1 - len(subCommand) - 4 capLines := cset.Strings(version, values, maxLen) for i, capStr := range capLines { if version >= caps.Cap302 && i < len(capLines)-1 {