diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-02-28 00:14:38 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-02-28 20:19:18 +0100 |
commit | 80b980b2af71faa9a2d825c61a5d41d7ace0dc60 (patch) | |
tree | 64056a5a5fb428869b62c6c0309155c67acbc432 /src/core/wee-input.c | |
parent | 64043d5a6c4ca258c40a8c39d0f58fc4a16c86b9 (diff) | |
download | weechat-80b980b2af71faa9a2d825c61a5d41d7ace0dc60.zip |
api: add function command_options (issue #928)
Diffstat (limited to 'src/core/wee-input.c')
-rw-r--r-- | src/core/wee-input.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/core/wee-input.c b/src/core/wee-input.c index 4037df2aa..00c7edc3c 100644 --- a/src/core/wee-input.c +++ b/src/core/wee-input.c @@ -39,6 +39,9 @@ #include "../plugins/plugin.h" +char **input_commands_allowed = NULL; + + /* * Sends data to buffer input callback. */ @@ -103,8 +106,25 @@ input_exec_command (struct t_gui_buffer *buffer, return WEECHAT_RC_ERROR; } - /* execute command */ rc = WEECHAT_RC_OK; + + /* check if command is allowed */ + if (input_commands_allowed + && !string_match_list (command_name + 1, + (const char **)input_commands_allowed, 0)) + { + if (weechat_debug_core >= 1) + { + gui_chat_printf_date_tags (NULL, 0, GUI_FILTER_TAG_NO_FILTER, + _("debug: command \"%s\" is not " + "allowed in this context"), + command_name); + } + rc = WEECHAT_RC_ERROR; + goto end; + } + + /* execute command */ switch (hook_command_exec (buffer, any_plugin, plugin, command)) { case HOOK_COMMAND_EXEC_OK: @@ -171,6 +191,7 @@ input_exec_command (struct t_gui_buffer *buffer, break; } +end: free (command); free (command_name); |