From ec816b4be5c3c5cd0ac3acb64e0f3e453eb1469b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Fri, 15 Oct 2021 19:25:43 +0200 Subject: [PATCH] irc: use parsed command parameters in "wallops" command callback --- src/plugins/irc/irc-protocol.c | 13 ++++++++++--- tests/unit/plugins/irc/test-irc-protocol.cpp | 7 +++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 2bbcd9331..6510dd232 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3320,19 +3320,23 @@ IRC_PROTOCOL_CALLBACK(topic) * Callback for the IRC command "WALLOPS". * * Command looks like: - * :nick!user@host WALLOPS :message from admin + * WALLOPS :message from admin */ IRC_PROTOCOL_CALLBACK(wallops) { const char *nick_address; + char *str_params; - IRC_PROTOCOL_MIN_ARGS(3); + IRC_PROTOCOL_MIN_PARAMS(1); if (ignored) return WEECHAT_RC_OK; nick_address = irc_protocol_nick_address (server, 0, NULL, nick, address); + + str_params = irc_protocol_string_params (params, 0, num_params - 1); + weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer (server, nick, command, NULL, NULL), date, @@ -3340,7 +3344,10 @@ IRC_PROTOCOL_CALLBACK(wallops) _("%sWallops from %s: %s"), weechat_prefix ("network"), (nick_address[0]) ? nick_address : "?", - (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]); + 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 c329f9dbe..212773abb 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -1927,9 +1927,12 @@ TEST(IrcProtocolWithServer, wallops) { SRV_INIT; - /* not enough arguments */ + /* not enough parameters */ RECV(":alice!user@host WALLOPS"); - CHECK_ERROR_ARGS("wallops", 2, 3); + CHECK_ERROR_PARAMS("wallops", 0, 1); + + RECV(":alice!user@host WALLOPS message"); + CHECK_SRV("-- Wallops from alice (user@host): message"); RECV(":alice!user@host WALLOPS :message from admin"); CHECK_SRV("-- Wallops from alice (user@host): message from admin");