patch 9.1.0451: No test for escaping '<' with shellescape()
Commit:
https://github.com/vim/vim/commit/88c8c547d5fc380e5685c2b01ec564ccdf9b259a
Author: zeertzjq <[email protected]>
Date: Thu May 30 19:27:25 2024 +0200
patch 9.1.0451: No test for escaping '<' with shellescape()
Problem: No test for escaping '<' with shellescape()
Solution: Add a test. Use memcpy() in code to make it easier to
understand. Fix a typo (zeertzjq).
closes: #14876
Signed-off-by: zeertzjq <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/strings.c b/src/strings.c
index 9b66ee0e4..6b2ff0a01 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -269,12 +269,12 @@ vim_strsave_shellescape(char_u *string, int do_special,
int do_newline)
*d++ = *p++;
continue;
}
- if (do_special && find_cmdline_var(p, &l) >= 0 && l > 0)
+ if (do_special && find_cmdline_var(p, &l) >= 0)
{
*d++ = '\'; // insert backslash
- do // copy the var
- *d++ = *p++;
- while (--l > 0);
+ memcpy(d, p, l); // copy the var
+ d += l;
+ p += l;
continue;
}
if (*p == '\' && fish_like)
diff --git a/src/structs.h b/src/structs.h
index b5341e3ba..804581bf1 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4795,7 +4795,7 @@ typedef struct soffset
typedef struct spat
{
char_u *pat; // the pattern (in allocated memory) or NULL
- size_t patlen; // the length of the patten (0 is pat is NULL)
+ size_t patlen; // the length of the pattern (0 if pat is NULL)
int magic; // magicness of the pattern
int no_scs; // no smartcase for this pattern
soffset_T off;
diff --git a/src/testdir/test_shell.vim b/src/testdir/test_shell.vim
index 7d91dff35..2ac559676 100644
--- a/src/testdir/test_shell.vim
+++ b/src/testdir/test_shell.vim
@@ -158,6 +158,10 @@ func Test_shellescape()
call assert_equal("'te\#xt'", shellescape("te#xt", 1))
call assert_equal("'te!xt'", shellescape("te!xt"))
call assert_equal("'te\!xt'", shellescape("te!xt", 1))
+ call assert_equal("'te<cword>xt'", shellescape("te<cword>xt"))
+ call assert_equal("'te\<cword>xt'", shellescape("te<cword>xt", 1))
+ call assert_equal("'te<cword>%xt'", shellescape("te<cword>%xt"))
+ call assert_equal("'te\<cword>\%xt'", shellescape("te<cword>%xt", 1))
call assert_equal("'te
xt'", shellescape("te
xt"))
call assert_equal("'te\
xt'", shellescape("te
xt", 1))
diff --git a/src/version.c b/src/version.c
index bedc35bf2..e90bd3074 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 451,
/**/
450,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/E1sCjbJ-00H90W-Bk%40256bit.org.