From 6124bf3c9255a5fb9ea667039cecb8563b2e7025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 16 Oct 2021 18:55:13 +0200 Subject: irc: use parsed command parameters in "729" command callback --- src/plugins/irc/irc-protocol.c | 26 ++++++++++++++++---------- tests/unit/plugins/irc/test-irc-protocol.cpp | 8 ++++---- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 02126f2c7..5338dfe15 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -6573,25 +6573,27 @@ IRC_PROTOCOL_CALLBACK(728) * Callback for the IRC command "729": end of quietlist. * * Command looks like: - * :server 729 mynick #channel mode :End of Channel Quiet List + * 729 mynick #channel mode :End of Channel Quiet List */ IRC_PROTOCOL_CALLBACK(729) { - char *pos_args; + char *str_params; struct t_irc_channel *ptr_channel; struct t_gui_buffer *ptr_buffer; struct t_irc_modelist *ptr_modelist; - IRC_PROTOCOL_MIN_ARGS(5); + IRC_PROTOCOL_MIN_PARAMS(3); - pos_args = (argc > 5) ? - ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL; + str_params = (num_params > 3) ? + irc_protocol_string_params (params, 3, num_params - 1) : NULL; - ptr_channel = irc_channel_search (server, argv[3]); + ptr_channel = irc_channel_search (server, params[1]); ptr_buffer = (ptr_channel && ptr_channel->nicks) ? ptr_channel->buffer : server->buffer; - ptr_modelist = irc_modelist_search (ptr_channel, argv[4][0]); + ptr_modelist = (ptr_channel) ? + irc_modelist_search (ptr_channel, params[2][0]) : NULL; + if (ptr_modelist) { if (ptr_modelist->state != IRC_MODELIST_STATE_RECEIVING) @@ -6604,6 +6606,7 @@ IRC_PROTOCOL_CALLBACK(729) } ptr_modelist->state = IRC_MODELIST_STATE_RECEIVED; } + weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "quietlist", ptr_buffer), @@ -6613,11 +6616,14 @@ IRC_PROTOCOL_CALLBACK(729) weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, - argv[3], + params[1], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); + (str_params) ? " " : "", + (str_params) ? str_params : ""); + + if (str_params) + free (str_params); 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 3b9a2387c..73a669ef0 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -3863,13 +3863,13 @@ TEST(IrcProtocolWithServer, 729) { SRV_INIT_JOIN; - /* not enough arguments */ + /* not enough parameters */ RECV(":server 729"); - CHECK_ERROR_ARGS("729", 2, 5); + CHECK_ERROR_PARAMS("729", 0, 3); RECV(":server 729 alice"); - CHECK_ERROR_ARGS("729", 3, 5); + CHECK_ERROR_PARAMS("729", 1, 3); RECV(":server 729 alice #test"); - CHECK_ERROR_ARGS("729", 4, 5); + CHECK_ERROR_PARAMS("729", 2, 3); RECV(":server 729 alice #test q"); CHECK_CHAN("-- [#test]"); -- cgit v1.2.3