summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-10-14 23:28:44 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-10-17 21:28:31 +0200
commit03e01221557cc60bc1a25e8b18f167e6b1319557 (patch)
tree2648afdee24fbef766c6d70d87c4a1b7c9895bbc /src/plugins
parent8d12187f3dccb412b36841d5780f63b7ef8ae3de (diff)
downloadweechat-03e01221557cc60bc1a25e8b18f167e6b1319557.zip
irc: use parsed command parameters in "setname" command callback
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-protocol.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 550fced10..f451977f2 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -2968,7 +2968,7 @@ IRC_PROTOCOL_CALLBACK(quit)
* (received when capability "setname" is enabled).
*
* Command looks like:
- * :nick!user@host SETNAME :the realname
+ * SETNAME :the realname
*/
IRC_PROTOCOL_CALLBACK(setname)
@@ -2976,13 +2976,16 @@ IRC_PROTOCOL_CALLBACK(setname)
int local_setname;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
- char *pos_realname, *realname_color;
+ char *str_params, *realname_color;
- IRC_PROTOCOL_MIN_ARGS(3);
+ IRC_PROTOCOL_MIN_PARAMS(1);
+ IRC_PROTOCOL_CHECK_NICK;
local_setname = (irc_server_strcasecmp (server, nick, server->nick) == 0);
- pos_realname = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];
+ str_params = irc_protocol_string_params (params, 0, num_params - 1);
+ if (!str_params)
+ return WEECHAT_RC_ERROR;
if (weechat_hashtable_has_key (server->cap_list, "setname"))
{
@@ -2994,7 +2997,7 @@ IRC_PROTOCOL_CALLBACK(setname)
{
if (ptr_nick->realname)
free (ptr_nick->realname);
- ptr_nick->realname = strdup (pos_realname);
+ ptr_nick->realname = strdup (str_params);
}
}
}
@@ -3002,7 +3005,7 @@ IRC_PROTOCOL_CALLBACK(setname)
if (!ignored)
{
realname_color = irc_color_decode (
- pos_realname,
+ str_params,
weechat_config_boolean (irc_config_network_colors_receive));
if (local_setname)
{
@@ -3031,6 +3034,8 @@ IRC_PROTOCOL_CALLBACK(setname)
free (realname_color);
}
+ free (str_params);
+
return WEECHAT_RC_OK;
}