diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 7e25b7b9d..191acb5f0 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -25,6 +25,7 @@ Bug fixes:: * core: display actual key name and command with key kbd:[Alt+k], remove key kbd:[Alt+K] (grab raw key) and associated commands `/input grab_raw_key` and `/input grab_raw_key_command` * irc: reply to a CTCP request sent to self nick (issue #1966) * irc: sent "QUIT" message to servers connected with TLS on `/upgrade` + * irc: fix display of country code in message 344 received as whois geo info (issue #1736) [[v4.0.0]] == Version 4.0.0 (2023-06-24) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 78bc69d1f..ab97587a4 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -5488,7 +5488,7 @@ IRC_PROTOCOL_CALLBACK(341) IRC_PROTOCOL_CALLBACK(344) { - char *str_host; + char *str_host, *str_params; IRC_PROTOCOL_MIN_PARAMS(3); @@ -5513,7 +5513,36 @@ IRC_PROTOCOL_CALLBACK(344) else { /* whois, geo info (UnrealIRCd) */ - IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg); + if (num_params >= 3) + { + str_params = irc_protocol_string_params ( + params, + (num_params >= 4) ? 3 : 2, + num_params - 1); + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer ( + server, params[1], command, "whois", NULL), + date, + irc_protocol_tags (server, command, tags, NULL, NULL, NULL), + "%s%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_params, + (num_params >= 4) ? " (" : "", + (num_params >= 4) ? params[2] : "", + (num_params >= 4) ? ")" : ""); + if (str_params) + free (str_params); + } + else + { + /* not enough arguments: use the default whois callback */ + IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg); + } } 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 36011b5c4..854047ca1 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -4325,7 +4325,12 @@ TEST(IrcProtocolWithServer, 344) /* whois, geo info (UnrealIRCd) */ RECV(":server 344 alice bob FR :is connecting from France"); - CHECK_SRV("--", "[bob] FR is connecting from France", + CHECK_SRV("--", "[bob] is connecting from France (FR)", + "irc_344,irc_numeric,log3"); + + /* whois, geo info (UnrealIRCd), no country code */ + RECV(":server 344 alice bob :is connecting from France"); + CHECK_SRV("--", "[bob] is connecting from France", "irc_344,irc_numeric,log3"); }