1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 04:16:38 +02:00

core: still split on printf when input_multiline isn't set

If we have chat lines with multiple lines in buffers without
input_multiline set, there can be an issue if a trigger is run on that
line. If the trigger runs a command which includes the message, then the
command is split (since input_multiline isn't set), and if any of the
lines in the message starts with a command, that command is executed.

To prevent this, only avoid splitting on newlines in printf if
input_multiline is set, so only such buffers can have chat lines with
newline characters.

See https://github.com/weechat/weechat/pull/1909 for more details.
This commit is contained in:
Trygve Aaberge
2023-04-19 09:09:24 +02:00
committed by Sébastien Helleu
parent 07fa6b12a6
commit e5573bfb4d
+32 -7
View File
@@ -849,6 +849,8 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
const char *tags, const char *message, ...)
{
time_t date_printed;
char *pos, *pos_end;
int one_line = 0;
if (!message)
return;
@@ -871,14 +873,37 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
if (date <= 0)
date = date_printed;
if (gui_init_ok)
pos = vbuffer;
while (pos)
{
gui_chat_printf_date_tags_internal (buffer, date, date_printed,
tags, vbuffer);
}
else
{
gui_chat_add_line_waiting_buffer (vbuffer);
if (!buffer || !buffer->input_multiline)
{
/* display until next end of line */
pos_end = strchr (pos, '\n');
if (pos_end)
pos_end[0] = '\0';
}
else
{
one_line = 1;
}
if (gui_init_ok)
{
gui_chat_printf_date_tags_internal (buffer, date, date_printed,
tags, pos);
}
else
{
gui_chat_add_line_waiting_buffer (pos);
}
if (one_line)
{
break;
}
pos = (pos_end && pos_end[1]) ? pos_end + 1 : NULL;
}
free (vbuffer);