From 0d6b18bc543fc34f0299f625625f1cf9e464b7ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 5 Jan 2022 08:24:04 +0100 Subject: [PATCH] irc: fix parsing of message 338 (whois, host) sent by Rizon server (closes #1737) --- ChangeLog.adoc | 1 + src/plugins/irc/irc-protocol.c | 52 ++++++++++++-------- tests/unit/plugins/irc/test-irc-protocol.cpp | 12 +++-- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index e40c77949..4f45c3420 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -27,6 +27,7 @@ New features:: Bug fixes:: * core: fix display of hotlist in buflist after changing value of option weechat.look.hotlist_sort (issue #1733) + * irc: fix parsing of message 338 (whois, host) sent by Rizon server (issue #1737) * irc: fix display of message 344 received as whois geo info (issue #1736) * irc: fix display of IRC numeric messages with no parameters diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 92396f353..080668ba0 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -4881,34 +4881,44 @@ IRC_PROTOCOL_CALLBACK(333) * * Command looks like: * 338 mynick nick host :actually using host + * + * On Rizon server: + * 338 mynick nick :is actually user@host [ip] */ IRC_PROTOCOL_CALLBACK(338) { char *str_text; - IRC_PROTOCOL_MIN_PARAMS(4); + IRC_PROTOCOL_MIN_PARAMS(3); - str_text = irc_protocol_string_params (params, 3, num_params - 1); - - weechat_printf_date_tags ( - irc_msgbuffer_get_target_buffer ( - server, params[1], command, "whois", NULL), - date, - irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL), - "%s%s[%s%s%s]%s %s %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - irc_nick_color_for_msg (server, 1, NULL, params[1]), - params[1], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_RESET, - str_text, - IRC_COLOR_CHAT_HOST, - params[2]); - - if (str_text) - free (str_text); + if (num_params < 4) + { + irc_protocol_cb_whois_nick_msg (server, date, irc_message, tags, nick, + address, host, command, ignored, + params, num_params); + } + else + { + str_text = irc_protocol_string_params (params, 3, num_params - 1); + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer ( + server, params[1], command, "whois", NULL), + date, + irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL), + "%s%s[%s%s%s]%s %s %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + irc_nick_color_for_msg (server, 1, NULL, params[1]), + params[1], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_RESET, + str_text, + IRC_COLOR_CHAT_HOST, + params[2]); + if (str_text) + free (str_text); + } return WEECHAT_RC_OK; } diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 11d67200e..dc7a601d8 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -2924,16 +2924,18 @@ TEST(IrcProtocolWithServer, 338) /* not enough parameters */ RECV(":server 338"); - CHECK_ERROR_PARAMS("338", 0, 4); + CHECK_ERROR_PARAMS("338", 0, 3); RECV(":server 338 alice"); - CHECK_ERROR_PARAMS("338", 1, 4); + CHECK_ERROR_PARAMS("338", 1, 3); RECV(":server 338 alice bob"); - CHECK_ERROR_PARAMS("338", 2, 4); - RECV(":server 338 alice bob hostname"); - CHECK_ERROR_PARAMS("338", 3, 4); + CHECK_ERROR_PARAMS("338", 2, 3); RECV(":server 338 alice bob hostname :actually using host"); CHECK_SRV("-- [bob] actually using host hostname"); + + /* on Rizon server */ + RECV(":server 338 alice bob :is actually bob@example.com [1.2.3.4]"); + CHECK_SRV("-- [bob] is actually bob@example.com [1.2.3.4]"); } /*