summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-04-19 09:09:24 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-04-19 16:47:44 +0200
commite5573bfb4d50c8a081812bf31be2a6d97e32f474 (patch)
tree4d2a388eda6045e4e618e92aec45ab4c4b1ca1cb /src/gui
parent07fa6b12a6d0e3f351050cad761bdaa467382bfb (diff)
downloadweechat-e5573bfb4d50c8a081812bf31be2a6d97e32f474.zip
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.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-chat.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 66c7ee681..eae62aa6a 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -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);