From cde0d5f7a5ad4ad4883e5046e481c73f88e79381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 17 Oct 2021 20:24:18 +0200 Subject: irc: do not display "*" when received as nick in command 900 --- src/plugins/irc/irc-protocol.c | 39 ++++++++++++++++++++-------- tests/unit/plugins/irc/test-irc-protocol.cpp | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 9266b96b1..43b06bd39 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -6823,27 +6823,44 @@ IRC_PROTOCOL_CALLBACK(734) * * Command looks like: * 900 mynick nick!user@host mynick :You are now logged in as mynick + * 900 * * mynick :You are now logged in as mynick */ IRC_PROTOCOL_CALLBACK(900) { char *str_params; + const char *pos_nick_host; IRC_PROTOCOL_MIN_PARAMS(4); + pos_nick_host = (strcmp (params[1], "*") != 0) ? params[1] : NULL; + str_params = irc_protocol_string_params (params, 3, num_params - 1); - weechat_printf_date_tags ( - irc_msgbuffer_get_target_buffer (server, params[1], command, NULL, NULL), - date, - irc_protocol_tags (command, "irc_numeric", NULL, NULL), - "%s%s %s(%s%s%s)", - weechat_prefix ("network"), - str_params, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - params[1], - IRC_COLOR_CHAT_DELIMITERS); + if (pos_nick_host) + { + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL, NULL), + "%s%s %s(%s%s%s)", + weechat_prefix ("network"), + str_params, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + pos_nick_host, + IRC_COLOR_CHAT_DELIMITERS); + } + else + { + weechat_printf_date_tags ( + irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL), + date, + irc_protocol_tags (command, "irc_numeric", NULL, NULL), + "%s%s", + weechat_prefix ("network"), + str_params); + } irc_server_free_sasl_data (server); diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 963482ce2..9daa1d110 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -4014,6 +4014,8 @@ TEST(IrcProtocolWithServer, 900) RECV(":server 900 alice alice!user@host alice " ":You are now logged in as mynick"); CHECK_SRV("-- You are now logged in as mynick (alice!user@host)"); + RECV(":server 900 * * alice :You are now logged in as mynick"); + CHECK_SRV("-- You are now logged in as mynick"); } /* -- cgit v1.2.3