summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2026-04-22 16:43:07 +0800
committerGitHub <noreply@github.com>2026-04-22 04:43:07 -0400
commit44770bb924844700e05aef4f81850f0378183ad9 (patch)
tree79ea8d67ac9e0fd7d1bd582f9902a505907e8381 /src
parent56fb9ed82de5082f2ce2ff869fdca42225a0204e (diff)
fix(cmd): ++p, ++edit should match "word" boundary #39146
Problem: `:write ++patate foo` doesn't error out, instead it turns on mkdir_p and uses "atate foo" as the filename. Same with ++edit. The parser just does strncmp without checking what comes after. Solution: require the next char after the option name to not be a letter
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 79c53b2900..1a29a61d22 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4366,14 +4366,14 @@ int getargopt(exarg_T *eap)
}
// ":read ++edit file"
- if (strncmp(arg, "edit", 4) == 0) {
+ if (strncmp(arg, "edit", 4) == 0 && !ASCII_ISALPHA(arg[4])) {
eap->read_edit = true;
eap->arg = skipwhite(arg + 4);
return OK;
}
// ":write ++p foo/bar/file
- if (strncmp(arg, "p", 1) == 0) {
+ if (arg[0] == 'p' && !ASCII_ISALPHA(arg[1])) {
eap->mkdir_p = true;
eap->arg = skipwhite(arg + 1);
return OK;