1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 05:46:38 +02:00

irc: use default callback in case of missing parameters in messages 311/312/327 (whois) and 314 (whowas)

This commit is contained in:
Sébastien Helleu
2022-01-06 08:12:32 +01:00
parent 6670fd2a87
commit 9bbab7ff02
3 changed files with 165 additions and 137 deletions
+1
View File
@@ -27,6 +27,7 @@ New features::
Bug fixes::
* core: fix display of hotlist in buflist after changing value of option weechat.look.hotlist_sort (issue #1733)
* irc: fix parsing of messages 311, 312, 327 (whois) and 314 (whowas) in case of missing parameters
* irc: fix parsing of message 338 (whois, host) sent by Rizon server (issue #1737)
* irc: fix display of message 344 received as whois geo info (issue #1736)
* irc: fix display of IRC numeric messages with no parameters
+132 -110
View File
@@ -4027,30 +4027,35 @@ IRC_PROTOCOL_CALLBACK(311)
{
char *str_realname;
IRC_PROTOCOL_MIN_PARAMS(6);
IRC_PROTOCOL_MIN_PARAMS(3);
str_realname = irc_protocol_string_params (params, 5, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] (%s%s@%s%s)%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname);
if (str_realname)
free (str_realname);
if (num_params < 6)
{
IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
}
else
{
str_realname = irc_protocol_string_params (params, 5, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] (%s%s@%s%s)%s: %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname);
if (str_realname)
free (str_realname);
}
return WEECHAT_RC_OK;
}
@@ -4066,30 +4071,35 @@ IRC_PROTOCOL_CALLBACK(312)
{
char *str_server;
IRC_PROTOCOL_MIN_PARAMS(4);
IRC_PROTOCOL_MIN_PARAMS(3);
str_server = irc_protocol_string_params (params, 3, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
params[2],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_server,
IRC_COLOR_CHAT_DELIMITERS);
if (str_server)
free (str_server);
if (num_params < 4)
{
IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
}
else
{
str_server = irc_protocol_string_params (params, 3, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whois", NULL),
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
params[2],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_server,
IRC_COLOR_CHAT_DELIMITERS);
if (str_server)
free (str_server);
}
return WEECHAT_RC_OK;
}
@@ -4105,30 +4115,35 @@ IRC_PROTOCOL_CALLBACK(314)
{
char *str_realname;
IRC_PROTOCOL_MIN_PARAMS(6);
IRC_PROTOCOL_MIN_PARAMS(3);
str_realname = irc_protocol_string_params (params, 5, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whowas", NULL),
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
_("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname);
if (str_realname)
free (str_realname);
if (num_params < 6)
{
IRC_PROTOCOL_RUN_CALLBACK(whowas_nick_msg);
}
else
{
str_realname = irc_protocol_string_params (params, 5, num_params - 1);
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, params[1], command, "whowas", NULL),
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
_("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"),
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname);
if (str_realname)
free (str_realname);
}
return WEECHAT_RC_OK;
}
@@ -4440,53 +4455,60 @@ IRC_PROTOCOL_CALLBACK(327)
char *str_realname;
struct t_gui_buffer *ptr_buffer;
IRC_PROTOCOL_MIN_PARAMS(4);
IRC_PROTOCOL_MIN_PARAMS(3);
str_realname = (num_params > 4) ?
irc_protocol_string_params (params, 4, num_params - 1) : NULL;
ptr_buffer = irc_msgbuffer_get_target_buffer (server, params[1],
command, "whois", NULL);
if (str_realname && str_realname[0])
if (num_params < 4)
{
weechat_printf_date_tags (
ptr_buffer,
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname,
IRC_COLOR_CHAT_DELIMITERS);
IRC_PROTOCOL_RUN_CALLBACK(whois_nick_msg);
}
else
{
weechat_printf_date_tags (
ptr_buffer,
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3]);
}
str_realname = (num_params > 4) ?
irc_protocol_string_params (params, 4, num_params - 1) : NULL;
if (str_realname)
free (str_realname);
ptr_buffer = irc_msgbuffer_get_target_buffer (server, params[1],
command, "whois", NULL);
if (str_realname && str_realname[0])
{
weechat_printf_date_tags (
ptr_buffer,
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s %s(%s%s%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
str_realname,
IRC_COLOR_CHAT_DELIMITERS);
}
else
{
weechat_printf_date_tags (
ptr_buffer,
date,
irc_protocol_tags (command, tags, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, params[1]),
params[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
params[2],
params[3]);
}
if (str_realname)
free (str_realname);
}
return WEECHAT_RC_OK;
}
+32 -27
View File
@@ -2484,20 +2484,20 @@ TEST(IrcProtocolWithServer, 311)
/* not enough parameters */
RECV(":server 311");
CHECK_ERROR_PARAMS("311", 0, 6);
CHECK_ERROR_PARAMS("311", 0, 3);
RECV(":server 311 alice");
CHECK_ERROR_PARAMS("311", 1, 6);
CHECK_ERROR_PARAMS("311", 1, 3);
RECV(":server 311 alice bob");
CHECK_ERROR_PARAMS("311", 2, 6);
CHECK_ERROR_PARAMS("311", 2, 3);
RECV(":server 311 alice bob user");
CHECK_ERROR_PARAMS("311", 3, 6);
RECV(":server 311 alice bob user host");
CHECK_ERROR_PARAMS("311", 4, 6);
RECV(":server 311 alice bob user host *");
CHECK_ERROR_PARAMS("311", 5, 6);
/* standard parameters */
RECV(":server 311 alice bob user host * :real name");
CHECK_SRV("-- [bob] (user@host): real name");
/* non-standard parameters (using default whois callback) */
RECV(":server 311 alice bob user");
CHECK_SRV("-- [bob] user");
}
/*
@@ -2511,16 +2511,19 @@ TEST(IrcProtocolWithServer, 312)
/* not enough parameters */
RECV(":server 312");
CHECK_ERROR_PARAMS("312", 0, 4);
CHECK_ERROR_PARAMS("312", 0, 3);
RECV(":server 312 alice");
CHECK_ERROR_PARAMS("312", 1, 4);
CHECK_ERROR_PARAMS("312", 1, 3);
RECV(":server 312 alice bob");
CHECK_ERROR_PARAMS("312", 2, 4);
RECV(":server 312 alice bob server");
CHECK_ERROR_PARAMS("312", 3, 4);
CHECK_ERROR_PARAMS("312", 2, 3);
/* standard parameters */
RECV(":server 312 alice bob server :https://example.com/");
CHECK_SRV("-- [bob] server (https://example.com/)");
/* non-standard parameters (using default whois callback) */
RECV(":server 312 alice bob server");
CHECK_SRV("-- [bob] server");
}
/*
@@ -2534,20 +2537,19 @@ TEST(IrcProtocolWithServer, 314)
/* not enough parameters */
RECV(":server 314");
CHECK_ERROR_PARAMS("314", 0, 6);
CHECK_ERROR_PARAMS("314", 0, 3);
RECV(":server 314 alice");
CHECK_ERROR_PARAMS("314", 1, 6);
CHECK_ERROR_PARAMS("314", 1, 3);
RECV(":server 314 alice bob");
CHECK_ERROR_PARAMS("314", 2, 6);
RECV(":server 314 alice bob user");
CHECK_ERROR_PARAMS("314", 3, 6);
RECV(":server 314 alice bob user host");
CHECK_ERROR_PARAMS("314", 4, 6);
RECV(":server 314 alice bob user host *");
CHECK_ERROR_PARAMS("314", 5, 6);
CHECK_ERROR_PARAMS("314", 2, 3);
/* standard parameters */
RECV(":server 314 alice bob user host * :real name");
CHECK_SRV("-- [bob] (user@host) was real name");
/* non-standard parameters (using default whowas callback) */
RECV(":server 314 alice bob user");
CHECK_SRV("-- [bob] user");
}
/*
@@ -2727,18 +2729,21 @@ TEST(IrcProtocolWithServer, 327)
/* not enough parameters */
RECV(":server 327");
CHECK_ERROR_PARAMS("327", 0, 4);
CHECK_ERROR_PARAMS("327", 0, 3);
RECV(":server 327 alice");
CHECK_ERROR_PARAMS("327", 1, 4);
CHECK_ERROR_PARAMS("327", 1, 3);
RECV(":server 327 alice bob");
CHECK_ERROR_PARAMS("327", 2, 4);
RECV(":server 327 alice bob host");
CHECK_ERROR_PARAMS("327", 3, 4);
CHECK_ERROR_PARAMS("327", 2, 3);
/* standard parameters */
RECV(":server 327 alice bob host 1.2.3.4");
CHECK_SRV("-- [bob] host 1.2.3.4");
RECV(":server 327 alice bob host 1.2.3.4 :real name");
CHECK_SRV("-- [bob] host 1.2.3.4 (real name)");
/* non-standard parameters (using default whois callback) */
RECV(":server 327 alice bob host");
CHECK_SRV("-- [bob] host");
}
/*