mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
api: add special value - (hyphen-minus) in options of function command_options to prevent execution of commands (issue #2199)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
### Changed
|
||||
|
||||
- api: return the buffer input callback return code in functions command and command_options
|
||||
- api: add special value `-` (hyphen-minus) in options of function command_options to prevent execution of commands
|
||||
- relay/api: allow array with multiple requests in websocket frame received from client
|
||||
- core, plugins: simplify help on parameters that can be repeated in commands
|
||||
|
||||
|
||||
@@ -16849,7 +16849,7 @@ rc = weechat.command(weechat.buffer_search("irc", "libera.#weechat"), "/whois Fl
|
||||
|
||||
==== command_options
|
||||
|
||||
_WeeChat ≥ 2.5, updated in 4.0.0._
|
||||
_WeeChat ≥ 2.5, updated in 4.0.0, 4.5.0._
|
||||
|
||||
Execute a command or send text to buffer with options.
|
||||
|
||||
@@ -16865,13 +16865,14 @@ Arguments:
|
||||
|
||||
* _buffer_: buffer pointer (command is executed on this buffer, use NULL for
|
||||
current buffer)
|
||||
* _command_: command to execute (if beginning with a "/"), or text to send to
|
||||
buffer
|
||||
* _command_: command to execute (if beginning with a `/` or a command char),
|
||||
or text to send to buffer
|
||||
* _options_: a hashtable with some options (keys and values must be string)
|
||||
(can be NULL):
|
||||
** _commands_: a comma-separated list of commands allowed to be executed during
|
||||
this call; see function <<_string_match_list,string_match_list>> for the
|
||||
format
|
||||
this call (see function <<_string_match_list,string_match_list>> for the
|
||||
format); the special value `-` (hyphen-minus) disables the execution of commands
|
||||
and the string in _command_ is sent as-is to the buffer (_WeeChat ≥ 4.5.0_)
|
||||
** _delay_: delay to execute command, in milliseconds
|
||||
** _split_newline_: `1` to split commands on newline char (`\n`) (_WeeChat ≥ 4.0.0_)
|
||||
|
||||
|
||||
@@ -17210,7 +17210,7 @@ rc = weechat.command(weechat.buffer_search("irc", "libera.#weechat"), "/whois Fl
|
||||
|
||||
==== command_options
|
||||
|
||||
_WeeChat ≥ 2.5, mis à jour dans la 4.0.0._
|
||||
_WeeChat ≥ 2.5, mis à jour dans la 4.0.0, 4.5.0._
|
||||
|
||||
Exécuter une commande ou envoyer du texte au tampon avec des options.
|
||||
|
||||
@@ -17226,13 +17226,15 @@ Paramètres :
|
||||
|
||||
* _buffer_ : pointeur vers le tampon (la commande est exécutée sur ce tampon,
|
||||
NULL pour le tampon courant)
|
||||
* _command_ : commande à exécuter (si elle commence par "/"), ou texte à
|
||||
envoyer au tampon
|
||||
* _command_ : commande à exécuter (si elle commence par `/` ou un caractère de
|
||||
commande), ou texte à envoyer au tampon
|
||||
* _options_ : table de hachage avec des options (les clés et valeurs doivent
|
||||
être des chaînes) (peut être NULL) :
|
||||
** _commands_ : une liste de commandes autorisées pendant l'appel, séparées par
|
||||
des virgules ; voir la fonction <<_string_match_list,string_match_list>>
|
||||
pour le format
|
||||
des virgules (voir la fonction <<_string_match_list,string_match_list>>
|
||||
pour le format) ; la valeur spéciale `-` (moins) désactive l'exécution des
|
||||
commandes et la chaîne dans _command_ est envoyée telle quelle au tampon
|
||||
(_WeeChat ≥ 4.5.0_)
|
||||
** _delay_ : délai pour exécuter la commande, en millisecondes
|
||||
** _split_newline_ : `1` pour découper les commandes sur le caractère de retour
|
||||
à la ligne (`\n`) (_WeeChat ≥ 4.0.0_)
|
||||
|
||||
@@ -17670,7 +17670,7 @@ rc = weechat.command(weechat.buffer_search("irc", "libera.#weechat"), "/whois Fl
|
||||
==== command_options
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 2.5, updated in 4.0.0._
|
||||
_WeeChat ≥ 2.5, updated in 4.0.0, 4.5.0._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Execute a command or send text to buffer with options.
|
||||
@@ -17687,14 +17687,17 @@ Argomenti:
|
||||
|
||||
* _buffer_: puntatore al buffer (il comando viene eseguito su questo buffer,
|
||||
utilizzare NULL per il buffer corrente)
|
||||
* _command_: comando da eseguire (se preceduto da "/"), oppure il testo
|
||||
viene inviato sul buffer
|
||||
// TRANSLATION MISSING
|
||||
* _command_: comando da eseguire (if beginning with a `/` or a command char),
|
||||
oppure il testo viene inviato sul buffer
|
||||
// TRANSLATION MISSING
|
||||
* _options_: a hashtable with some options (keys and values must be string)
|
||||
(can be NULL):
|
||||
// TRANSLATION MISSING
|
||||
** _commands_: a comma-separated list of commands allowed to be executed during
|
||||
this call; see function <<_string_match_list,string_match_list>> for the
|
||||
format
|
||||
this call (see function <<_string_match_list,string_match_list>> for the
|
||||
format); the special value `-` (hyphen-minus) disables the execution of commands
|
||||
and the string in _command_ is sent as-is to the buffer (_WeeChat ≥ 4.5.0_)
|
||||
** _delay_: delay to execute command, in milliseconds
|
||||
// TRANSLATION MISSING
|
||||
** _split_newline_: `1` to split commands on newline char (`\n`) (_WeeChat ≥ 4.0.0_)
|
||||
|
||||
@@ -17133,7 +17133,7 @@ rc = weechat.command(weechat.buffer_search("irc", "libera.#weechat"), "/whois Fl
|
||||
==== command_options
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 2.5, updated in 4.0.0._
|
||||
_WeeChat ≥ 2.5, updated in 4.0.0, 4.5.0._
|
||||
|
||||
バッファにてオプション付きでコマンドを実行またはテキストを送信
|
||||
|
||||
@@ -17149,14 +17149,17 @@ int weechat_command_options (struct t_gui_buffer *buffer, const char *command,
|
||||
|
||||
* _buffer_: バッファへのポインタ
|
||||
(コマンドは指定したバッファで実行されます、現在のバッファで実行するには NULL を指定してください)
|
||||
* _command_: 実行するコマンド ("/"
|
||||
で始まっている場合)、またはバッファに送信するテキスト
|
||||
// TRANSLATION MISSING
|
||||
* _command_: 実行するコマンド (if beginning with a `/` or a command char)、またはバッファに送信するテキスト
|
||||
* _options_: オプションを含むハッシュテーブル (キーと値は文字列です)
|
||||
(NULL は使えません):
|
||||
* _options_: a hashtable with some options (keys and values must be string)
|
||||
(can be NULL):
|
||||
// TRANSLATION MISSING
|
||||
** _commands_: 指定したコマンドの中で実行を許可するコマンドのカンマ区切りリスト、リストの書式は関数
|
||||
<<_string_match_list,string_match_list>> を参考にしてください
|
||||
<<_string_match_list,string_match_list>> を参考にしてください;
|
||||
the special value `-` (hyphen-minus) disables the execution of commands
|
||||
and the string in _command_ is sent as-is to the buffer (_WeeChat ≥ 4.5.0_)
|
||||
** _delay_: コマンド実行までの遅延時間、ミリ秒単位
|
||||
// TRANSLATION MISSING
|
||||
** _split_newline_: `1` to split commands on newline char (`\n`) (_WeeChat ≥ 4.0.0_)
|
||||
|
||||
@@ -16399,7 +16399,7 @@ rc = weechat.command(weechat.buffer_search("irc", "libera.#weechat"), "/whois Fl
|
||||
|
||||
==== command_options
|
||||
|
||||
_WeeChat ≥ 2.5, ажурирано у верзији 4.0.0._
|
||||
_WeeChat ≥ 2.5, ажурирано у верзији 4.0.0, 4.5.0._
|
||||
|
||||
Извршава команду или шаље текст у бафер са опцијама.
|
||||
|
||||
@@ -16414,9 +16414,14 @@ int weechat_command_options (struct t_gui_buffer *buffer, const char *command,
|
||||
Аргументи:
|
||||
|
||||
* _buffer_: показивач на бафер (команда се извршава у овом баферу, употребите NULL за текући бафер)
|
||||
* _command_: команда која се извршава (ако почиње са „/”), или текст који се шаље у бафер
|
||||
// TRANSLATION MISSING
|
||||
* _command_: команда која се извршава (if beginning with a `/` or a command char), или текст који се шаље у бафер
|
||||
* _options_: хеш табела са неким опцијама (кључеви и вредности морају бити стринг) (може да буде NULL):
|
||||
** _commands_: листа команди које смеју да се изврше током овог позива раздвојене запетама; за формат, погледајте функцију <<_string_match_list,string_match_list>>
|
||||
// TRANSLATION MISSING
|
||||
** _commands_: листа команди које смеју да се изврше током овог позива раздвојене запетама
|
||||
(за формат, погледајте функцију <<_string_match_list,string_match_list>>);
|
||||
the special value `-` (hyphen-minus) disables the execution of commands
|
||||
and the string in _command_ is sent as-is to the buffer (_WeeChat ≥ 4.5.0_)
|
||||
** _delay_: пауза за извршавање команде, у милисекундама
|
||||
** _split_newline_: `1` да се команде поделе на карактеру прелома линије (`\n`) (_WeeChat ≥ 4.0.0_)
|
||||
|
||||
|
||||
+14
-3
@@ -327,9 +327,20 @@ input_data (struct t_gui_buffer *buffer, const char *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* execute command on buffer */
|
||||
rc = input_exec_command (buffer, 1, buffer->plugin, ptr_data,
|
||||
commands_allowed);
|
||||
/*
|
||||
* if commands_allowed has special value "-", send data as-is
|
||||
* to the buffer input callback, otherwise execute the command
|
||||
* on the buffer
|
||||
*/
|
||||
if (commands_allowed && (strcmp (commands_allowed, "-") == 0))
|
||||
{
|
||||
rc = input_exec_data (buffer, ptr_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = input_exec_command (buffer, 1, buffer->plugin,
|
||||
ptr_data, commands_allowed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,6 +182,15 @@ TEST(CoreInput, Data)
|
||||
RECORD_CHECK_MSG("core.test", "", "line2", NULL);
|
||||
LONGS_EQUAL(2, record_count_messages ());
|
||||
|
||||
/* on core buffer: valid command but with commands disabled */
|
||||
TEST_INPUT_DATA(WEECHAT_RC_ERROR, gui_buffers, "/print core\n/print line2", "-", 0, 0);
|
||||
RECORD_CHECK_MSG("core.weechat", "=!=", "You cannot write text in this buffer", NULL);
|
||||
LONGS_EQUAL(1, record_count_messages ());
|
||||
|
||||
/* on test buffer: valid command but with commands disabled */
|
||||
TEST_INPUT_DATA(WEECHAT_RC_OK, buffer, "/print core\n/print line2", "-", 0, 0);
|
||||
RECORD_CHECK_NO_MSG();
|
||||
|
||||
gui_buffer_close (buffer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user