summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-16 19:29:45 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commita3ddeba9f9a4a0efe44bc81af234375a4682d561 (patch)
tree5e933472b6996a0de43fc95eff23176ea3f94d5d
parentbaa91a45a8538a05ee92f89f6adae6864bd218c5 (diff)
downloadweechat-a3ddeba9f9a4a0efe44bc81af234375a4682d561.zip
irc: use parsed command parameters in "900" command callback
-rw-r--r--src/plugins/irc/irc-protocol.c17
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp10
2 files changed, 17 insertions, 10 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f48da7145..7e22378b5 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -6822,27 +6822,34 @@ IRC_PROTOCOL_CALLBACK(734)
* Callback for the IRC command "900": logged in as (SASL).
*
* Command looks like:
- * :server 900 mynick nick!user@host mynick :You are now logged in as mynick
+ * 900 mynick nick!user@host mynick :You are now logged in as mynick
*/
IRC_PROTOCOL_CALLBACK(900)
{
- IRC_PROTOCOL_MIN_ARGS(6);
+ char *str_params;
+
+ IRC_PROTOCOL_MIN_PARAMS(4);
+
+ str_params = irc_protocol_string_params (params, 3, num_params - 1);
weechat_printf_date_tags (
- irc_msgbuffer_get_target_buffer (server, argv[3], command, NULL, NULL),
+ 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"),
- (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5],
+ str_params,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- argv[3],
+ params[1],
IRC_COLOR_CHAT_DELIMITERS);
irc_server_free_sasl_data (server);
+ 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 6abbbd043..71f0204ec 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -4004,15 +4004,15 @@ TEST(IrcProtocolWithServer, 900)
{
SRV_INIT;
- /* not enough arguments */
+ /* not enough parameters */
RECV(":server 900");
- CHECK_ERROR_ARGS("900", 2, 6);
+ CHECK_ERROR_PARAMS("900", 0, 4);
RECV(":server 900 alice");
- CHECK_ERROR_ARGS("900", 3, 6);
+ CHECK_ERROR_PARAMS("900", 1, 4);
RECV(":server 900 alice alice!user@host");
- CHECK_ERROR_ARGS("900", 4, 6);
+ CHECK_ERROR_PARAMS("900", 2, 4);
RECV(":server 900 alice alice!user@host alice");
- CHECK_ERROR_ARGS("900", 5, 6);
+ CHECK_ERROR_PARAMS("900", 3, 4);
RECV(":server 900 alice alice!user@host alice logged");
CHECK_SRV("-- logged (alice!user@host)");