irc: split server command before evaluating it (issue #1643)
This commit is contained in:
parent
4065972000
commit
e350437c81
@ -52,6 +52,7 @@ Bug fixes::
|
||||
* core: prevent switching to start of visited buffers when jumping to next (issue #1591, issue #1592)
|
||||
* core: recreate buflist and fset bars on /reload when WeeChat is started without configuration files (issue #1618)
|
||||
* buflist: fix comparison of hotlists in option buflist.look.sort (issue #1621)
|
||||
* irc: split server command before evaluating it (issue #1643)
|
||||
* xfer: make file transfer fail when option xfer.file.auto_rename is off and file already exists (issue #1633)
|
||||
|
||||
Tests::
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
command3 = irc_message_replace_vars (server, NULL,
|
||||
command2);
|
||||
if (command3)
|
||||
{
|
||||
weechat_command (server->buffer, command2);
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user