summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-05-22 08:24:47 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-05-22 08:48:24 +0200
commite350437c816c8035a5a45b6fbe8b8a40bd5c7647 (patch)
tree2abab72aa622f265b075884607c23e9aabb162e2 /src/plugins
parent4065972000133f6da2c80b23a26ba49bd6218302 (diff)
downloadweechat-e350437c816c8035a5a45b6fbe8b8a40bd5c7647.zip
irc: split server command before evaluating it (issue #1643)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/irc/irc-config.c2
-rw-r--r--src/plugins/irc/irc-protocol.c47
2 files changed, 27 insertions, 22 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index ebb6c37c0..0f143625a 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -2150,7 +2150,7 @@ irc_config_server_new_option (struct t_config_file *config_file,
"auto-join of channels (many commands can be separated by "
"\";\", use \"\\;\" for a semicolon, special variables "
"$nick, $channel and $server are replaced by their value) "
- "(note: content is evaluated, see /help eval; server "
+ "(note: commands are evaluated, see /help eval; server "
"options are evaluated with ${irc_server.xxx} and "
"${server} is replaced by the server name)"),
NULL, 0, 0,
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index f5f91b9e0..183b83d78 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -2977,8 +2977,9 @@ IRC_PROTOCOL_CALLBACK(wallops)
IRC_PROTOCOL_CALLBACK(001)
{
- char *server_command, **commands, **ptr_command, *command2, *slash_command;
+ char **commands, **ptr_command, *command2, *command3, *slash_command;
char *away_msg, *usermode;
+ const char *ptr_server_command;
int length;
IRC_PROTOCOL_MIN_ARGS(3);
@@ -3035,35 +3036,41 @@ IRC_PROTOCOL_CALLBACK(001)
free (usermode);
/* execute command when connected */
- server_command = irc_server_eval_expression (
- server,
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_COMMAND));
- if (server_command && server_command[0])
+ ptr_server_command = IRC_SERVER_OPTION_STRING(server,
+ IRC_SERVER_OPTION_COMMAND);
+ if (ptr_server_command && ptr_server_command[0])
{
/* split command on ';' which can be escaped with '\;' */
- commands = weechat_string_split_command (server_command, ';');
+ commands = weechat_string_split_command (ptr_server_command, ';');
if (commands)
{
for (ptr_command = commands; *ptr_command; ptr_command++)
{
- command2 = irc_message_replace_vars (server, NULL,
- *ptr_command);
+ command2 = irc_server_eval_expression (server, *ptr_command);
if (command2)
{
- if (weechat_string_is_command_char (command2))
- {
- weechat_command (server->buffer, command2);
- }
- else
+ command3 = irc_message_replace_vars (server, NULL,
+ command2);
+ if (command3)
{
- length = 1 + strlen(command2) + 1;
- slash_command = malloc (length);
- if (slash_command)
+ if (weechat_string_is_command_char (command3))
{
- snprintf (slash_command, length, "/%s", command2);
- weechat_command (server->buffer, slash_command);
- free (slash_command);
+ weechat_command (server->buffer, command3);
+ }
+ else
+ {
+ length = 1 + strlen(command3) + 1;
+ slash_command = malloc (length);
+ if (slash_command)
+ {
+ snprintf (slash_command, length,
+ "/%s", command3);
+ weechat_command (server->buffer,
+ slash_command);
+ free (slash_command);
+ }
}
+ free (command3);
}
free (command2);
}
@@ -3080,8 +3087,6 @@ IRC_PROTOCOL_CALLBACK(001)
{
irc_server_autojoin_channels (server);
}
- if (server_command)
- free (server_command);
return WEECHAT_RC_OK;
}