diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 5748df3c2..5fcb5527f 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -5279,29 +5279,33 @@ IRC_PROTOCOL_CALLBACK(349) * Callback for the IRC command "351": server version. * * Command looks like: - * :server 351 mynick dancer-ircd-1.0.36(2006/07/23_13:11:50). server :iMZ dncrTS/v4 + * 351 mynick dancer-ircd-1.0.36(2006/07/23_13:11:50). server :iMZ dncrTS/v4 */ IRC_PROTOCOL_CALLBACK(351) { + char *str_params; struct t_gui_buffer *ptr_buffer; - IRC_PROTOCOL_MIN_ARGS(5); + IRC_PROTOCOL_MIN_PARAMS(3); ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL); - if (argc > 5) + if (num_params > 3) { + str_params = irc_protocol_string_params (params, 3, num_params - 1); weechat_printf_date_tags ( ptr_buffer, date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s %s (%s)", weechat_prefix ("network"), - argv[3], - argv[4], - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]); + params[1], + params[2], + str_params); + if (str_params) + free (str_params); } else { @@ -5311,8 +5315,8 @@ IRC_PROTOCOL_CALLBACK(351) irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s %s", weechat_prefix ("network"), - argv[3], - argv[4]); + params[1], + params[2]); } 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 6ae32ad00..6d78a46ad 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -3109,13 +3109,13 @@ TEST(IrcProtocolWithServer, 351) { SRV_INIT; - /* not enough arguments */ + /* not enough parameters */ RECV(":server 351"); - CHECK_ERROR_ARGS("351", 2, 5); + CHECK_ERROR_PARAMS("351", 0, 3); RECV(":server 351 alice"); - CHECK_ERROR_ARGS("351", 3, 5); + CHECK_ERROR_PARAMS("351", 1, 3); RECV(":server 351 alice dancer-ircd-1.0"); - CHECK_ERROR_ARGS("351", 4, 5); + CHECK_ERROR_PARAMS("351", 2, 3); RECV(":server 351 alice dancer-ircd-1.0 server"); CHECK_SRV("-- dancer-ircd-1.0 server");