1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 15:26:37 +02:00

core: fix execution of multiple commands separated by newline when there are no spaces

For example typing this on core buffer:

/t1
/t2

was not executing the two commands but sent the text to the buffer instead.

This is because WeeChat thinks it's a path, and the newline should indicate
it's not (like a space before the next slash: "/t1 /t2" is a command, not a
path, but "/t1/t2" is considered a path).
This commit is contained in:
Sébastien Helleu
2023-05-05 20:28:11 +02:00
parent 25d7192677
commit 6d7f10ef20
2 changed files with 30 additions and 4 deletions
+8 -4
View File
@@ -3909,7 +3909,7 @@ string_is_command_char (const char *string)
const char *
string_input_for_buffer (const char *string)
{
char *pos_slash, *pos_space;
char *pos_slash, *pos_space, *pos_newline;
const char *next_char;
if (!string)
@@ -3925,18 +3925,22 @@ string_input_for_buffer (const char *string)
/*
* special case if string starts with '/': to allow to paste a path line
* "/path/to/file.txt", we check if next '/' is after a space or not
* "/path/to/file.txt", we check if next '/' is after a space/newline
* or not
*/
if (string[0] == '/')
{
pos_slash = strchr (string + 1, '/');
pos_space = strchr (string + 1, ' ');
pos_newline = strchr (string + 1, '\n');
/*
* if there are no other '/' or if '/' is after first space,
* if there are no other '/' or if '/' is after first space/newline,
* then it is a command, and return NULL
*/
if (!pos_slash || (pos_space && pos_slash > pos_space))
if (!pos_slash
|| (pos_space && (pos_slash > pos_space))
|| (pos_newline && (pos_slash > pos_newline)))
return NULL;
return (string[1] == '/') ? string + 1 : string;