1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

exec: fix unexpected execution of command with /exec -o when the command starts with two command chars (closes #2199)

This commit is contained in:
Sébastien Helleu
2024-10-13 11:12:53 +02:00
parent bca7c7438a
commit 90c23ef418
2 changed files with 19 additions and 28 deletions
+1
View File
@@ -20,6 +20,7 @@
- irc: decode IRC colors only when displaying messages in buffer, store nick info with IRC colors (host, account, real name)
- irc: do not strip trailing spaces from incoming IRC messages
- irc: fix crash on /list buffer when a filter is set ([#2197](https://github.com/weechat/weechat/issues/2197))
- exec: fix unexpected execution of command with `/exec -o` when the command starts with two command chars ([#2199](https://github.com/weechat/weechat/issues/2199))
- relay/api: fix empty nicklist in remote buffers after connection or reconnection
- core: always send the signal "buffer_switch", even when the buffer is opening ([#2198](https://github.com/weechat/weechat/issues/2198))
- lua: fix compilation on Fedora with Lua < 5.2.0 ([#2173](https://github.com/weechat/weechat/issues/2173), [#2174](https://github.com/weechat/weechat/issues/2174))
+18 -28
View File
@@ -242,8 +242,8 @@ void
exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
int out, const char *line)
{
char *line_color, *line_color2, *line2, str_number[32], str_tags[1024];
const char *ptr_line_color;
struct t_hashtable *options;
char *line_color, *line2, str_number[32], str_tags[1024];
int length;
if (!exec_cmd || !line)
@@ -268,6 +268,15 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
if (!line_color)
return;
options = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
if (!options)
return;
if (!exec_cmd->output_to_buffer_exec_cmd)
weechat_hashtable_set (options, "commands", "-");
exec_cmd->output_line_nb++;
if (exec_cmd->pipe_command)
@@ -279,7 +288,7 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
"$line", line_color);
if (line2)
{
weechat_command (buffer, line2);
weechat_command_options (buffer, line2, options);
free (line2);
}
}
@@ -292,7 +301,7 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
{
snprintf (line2, length,
"%s %s", exec_cmd->pipe_command, line_color);
weechat_command (buffer, line2);
weechat_command_options (buffer, line2, options);
free (line2);
}
}
@@ -307,35 +316,15 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
{
snprintf (line2, length,
"%d. %s", exec_cmd->output_line_nb, line_color);
weechat_command (buffer, line2);
weechat_command_options (buffer, line2, options);
free (line2);
}
}
else
{
if (exec_cmd->output_to_buffer_exec_cmd)
ptr_line_color = line_color;
else
ptr_line_color = weechat_string_input_for_buffer (line_color);
if (ptr_line_color)
{
weechat_command (buffer,
(ptr_line_color[0]) ? ptr_line_color : " ");
}
else
{
length = 1 + strlen (line_color) + 1;
line_color2 = malloc (length);
if (line_color2)
{
snprintf (line_color2, length, "%c%s",
line_color[0], line_color);
weechat_command (buffer,
(line_color2[0]) ? line_color2 : " ");
free (line_color2);
}
}
weechat_command_options (buffer,
(line_color[0]) ? line_color : " ",
options);
}
}
else
@@ -367,6 +356,7 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer,
}
}
weechat_hashtable_free (options);
free (line_color);
}