mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Don't allow recursive aliases.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@517 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
f83f64b6be
commit
a3a066e9cf
@ -36,6 +36,8 @@ char *current_command;
|
|||||||
static GSList *cmdget_funcs;
|
static GSList *cmdget_funcs;
|
||||||
static int signal_default_command;
|
static int signal_default_command;
|
||||||
|
|
||||||
|
static GSList *alias_runstack;
|
||||||
|
|
||||||
COMMAND_REC *command_find(const char *cmd)
|
COMMAND_REC *command_find(const char *cmd)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
@ -572,6 +574,15 @@ void cmd_get_remove_func(CMD_GET_FUNC func)
|
|||||||
cmdget_funcs = g_slist_prepend(cmdget_funcs, (void *) func);
|
cmdget_funcs = g_slist_prepend(cmdget_funcs, (void *) func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define alias_runstack_push(alias) \
|
||||||
|
alias_runstack = g_slist_append(alias_runstack, alias)
|
||||||
|
|
||||||
|
#define alias_runstack_pop(alias) \
|
||||||
|
alias_runstack = g_slist_remove(alias_runstack, alias)
|
||||||
|
|
||||||
|
#define alias_runstack_find(alias) \
|
||||||
|
(gslist_find_icase_string(alias_runstack, alias) != NULL)
|
||||||
|
|
||||||
static void parse_command(const char *command, int expand_aliases,
|
static void parse_command(const char *command, int expand_aliases,
|
||||||
SERVER_REC *server, void *item)
|
SERVER_REC *server, void *item)
|
||||||
{
|
{
|
||||||
@ -582,10 +593,14 @@ static void parse_command(const char *command, int expand_aliases,
|
|||||||
args = strchr(cmd+8, ' ');
|
args = strchr(cmd+8, ' ');
|
||||||
if (args != NULL) *args++ = '\0'; else args = "";
|
if (args != NULL) *args++ = '\0'; else args = "";
|
||||||
|
|
||||||
/* check if there's an alias for command */
|
/* check if there's an alias for command. Don't allow
|
||||||
alias = expand_aliases ? alias_find(cmd+8) : NULL;
|
recursive aliases */
|
||||||
|
alias = !expand_aliases || alias_runstack_find(cmd+8) ? NULL :
|
||||||
|
alias_find(cmd+8);
|
||||||
if (alias != NULL) {
|
if (alias != NULL) {
|
||||||
|
alias_runstack_push(cmd+8);
|
||||||
eval_special_string(alias, args, server, item);
|
eval_special_string(alias, args, server, item);
|
||||||
|
alias_runstack_pop(cmd+8);
|
||||||
g_free(orig);
|
g_free(orig);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -678,6 +693,7 @@ void commands_init(void)
|
|||||||
commands = NULL;
|
commands = NULL;
|
||||||
cmdget_funcs = NULL;
|
cmdget_funcs = NULL;
|
||||||
current_command = NULL;
|
current_command = NULL;
|
||||||
|
alias_runstack = NULL;
|
||||||
|
|
||||||
signal_default_command = signal_get_uniq_id("default command");
|
signal_default_command = signal_get_uniq_id("default command");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user