summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-16 18:36:21 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commit5e63161b5b3fa6eee71a73c17667b3a1cfd8d365 (patch)
treee105d5e0d8010da4e994cb38ba2245a863586025
parent32c99047f4972c3a06f9c320f0fde0b33799e189 (diff)
downloadweechat-5e63161b5b3fa6eee71a73c17667b3a1cfd8d365.zip
irc: use parsed command parameters in "438" command callback
-rw-r--r--src/plugins/irc/irc-protocol.c20
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp6
2 files changed, 15 insertions, 11 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 8bff30513..e99e70b7c 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -6297,29 +6297,33 @@ IRC_PROTOCOL_CALLBACK(437)
* Callback for the IRC command "438": not authorized to change nickname.
*
* Command looks like:
- * :server 438 mynick newnick :Nick change too fast. Please wait 30 seconds.
+ * 438 mynick newnick :Nick change too fast. Please wait 30 seconds.
*/
IRC_PROTOCOL_CALLBACK(438)
{
+ char *str_params;
struct t_gui_buffer *ptr_buffer;
- IRC_PROTOCOL_MIN_ARGS(4);
+ IRC_PROTOCOL_MIN_PARAMS(2);
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, 2, 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_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4],
- argv[2],
- argv[3]);
+ str_params,
+ params[0],
+ params[1]);
+ if (str_params)
+ free (str_params);
}
else
{
@@ -6329,8 +6333,8 @@ IRC_PROTOCOL_CALLBACK(438)
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s %s",
weechat_prefix ("network"),
- argv[2],
- argv[3]);
+ params[0],
+ params[1]);
}
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 cb0d5754c..91c8746f5 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -3774,11 +3774,11 @@ TEST(IrcProtocolWithServer, 438)
{
SRV_INIT;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 438");
- CHECK_ERROR_ARGS("438", 2, 4);
+ CHECK_ERROR_PARAMS("438", 0, 2);
RECV(":server 438 alice");
- CHECK_ERROR_ARGS("438", 3, 4);
+ CHECK_ERROR_PARAMS("438", 1, 2);
RECV(":server 438 alice alice2");
CHECK_SRV("-- alice alice2");