diff options
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 26 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 5 |
2 files changed, 21 insertions, 10 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 616f00e44..de21811b3 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3799,15 +3799,18 @@ IRC_PROTOCOL_CALLBACK(303) * Callback for the IRC command "305": unaway. * * Command looks like: - * :server 305 mynick :Does this mean you're really back? + * 305 mynick :Does this mean you're really back? */ IRC_PROTOCOL_CALLBACK(305) { - IRC_PROTOCOL_MIN_ARGS(3); + char *str_params; + + IRC_PROTOCOL_MIN_PARAMS(1); - if (argc > 3) + if (num_params > 1) { + str_params = irc_protocol_string_params (params, 1, num_params - 1); weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "unaway", NULL), @@ -3815,7 +3818,9 @@ IRC_PROTOCOL_CALLBACK(305) irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s", weechat_prefix ("network"), - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + str_params); + if (str_params) + free (str_params); } server->is_away = 0; @@ -3830,15 +3835,18 @@ IRC_PROTOCOL_CALLBACK(305) * Callback for the IRC command "306": now away. * * Command looks like: - * :server 306 mynick :We'll miss you + * 306 mynick :We'll miss you */ IRC_PROTOCOL_CALLBACK(306) { - IRC_PROTOCOL_MIN_ARGS(3); + char *str_params; + + IRC_PROTOCOL_MIN_PARAMS(1); - if (argc > 3) + if (num_params > 1) { + str_params = irc_protocol_string_params (params, 1, num_params - 1); weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "away", NULL), @@ -3846,7 +3854,9 @@ IRC_PROTOCOL_CALLBACK(306) irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s", weechat_prefix ("network"), - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + str_params); + if (str_params) + free (str_params); } server->is_away = 1; diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 8eeac3df9..86ebc42b6 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -2311,10 +2311,11 @@ TEST(IrcProtocolWithServer, 305_306) RECV(":bob!user@host PRIVMSG alice :hi Alice!"); CHECK_PV("bob", "bob hi Alice!"); - /* not enough arguments */ + /* not enough parameters */ RECV(":server 305"); - CHECK_ERROR_ARGS("305", 2, 3); + CHECK_ERROR_PARAMS("305", 0, 1); RECV(":server 306"); + CHECK_ERROR_PARAMS("306", 0, 1); POINTERS_EQUAL(NULL, ptr_server->channels->away_message); |