patch 9.1.1607: :apple command detected as :append

Problem:  :apple command detected as :append (dai475694450)
Solution: Disallow to define a custom command with lower-case letter,
          correctly detect :insert/:change/:append ex commands
          (Hirohito Higashi).

fixes: #17893
closes: #17930

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito Higashi
2025-08-08 13:25:27 +02:00
committed by Christian Brabandt
parent eb2aebeb79
commit efd83d441b
3 changed files with 55 additions and 13 deletions
+7 -13
View File
@@ -1282,21 +1282,15 @@ get_function_body(
}
// Check for ":append", ":change", ":insert". Not for :def.
p = skip_range(p, FALSE, NULL);
char_u *tp = p = skip_range(p, FALSE, NULL);
if (!vim9_function
&& ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c'
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'h'
&& (!ASCII_ISALPHA(p[2]) || (p[2] == 'a'
&& (STRNCMP(&p[3], "nge", 3) != 0
|| !ASCII_ISALPHA(p[6])))))))
|| (p[0] == 'i'
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
&& (!ASCII_ISALPHA(p[2])
|| (p[2] == 's'
&& (!ASCII_ISALPHA(p[3])
|| p[3] == 'e'))))))))
&& (checkforcmd(&p, "append", 1)
|| checkforcmd(&p, "change", 1)
|| checkforcmd(&p, "insert", 1))
&& (*p == '!' || *p == '|' || IS_WHITE_NL_OR_NUL(*p)))
skip_until = vim_strnsave((char_u *)".", 1);
else
p = tp;
// Check for ":python <<EOF", ":tcl <<EOF", etc.
arg = skipwhite(skiptowhite(p));