mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
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 <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
32a5faa6d7
commit
88c8c547d5
@@ -269,12 +269,12 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline)
|
|||||||
*d++ = *p++;
|
*d++ = *p++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (do_special && find_cmdline_var(p, &l) >= 0 && l > 0)
|
if (do_special && find_cmdline_var(p, &l) >= 0)
|
||||||
{
|
{
|
||||||
*d++ = '\\'; // insert backslash
|
*d++ = '\\'; // insert backslash
|
||||||
do // copy the var
|
memcpy(d, p, l); // copy the var
|
||||||
*d++ = *p++;
|
d += l;
|
||||||
while (--l > 0);
|
p += l;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (*p == '\\' && fish_like)
|
if (*p == '\\' && fish_like)
|
||||||
|
@@ -4795,7 +4795,7 @@ typedef struct soffset
|
|||||||
typedef struct spat
|
typedef struct spat
|
||||||
{
|
{
|
||||||
char_u *pat; // the pattern (in allocated memory) or NULL
|
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 magic; // magicness of the pattern
|
||||||
int no_scs; // no smartcase for this pattern
|
int no_scs; // no smartcase for this pattern
|
||||||
soffset_T off;
|
soffset_T off;
|
||||||
|
@@ -158,6 +158,10 @@ func Test_shellescape()
|
|||||||
call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
|
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"))
|
||||||
call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
|
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\nxt'", shellescape("te\nxt"))
|
call assert_equal("'te\nxt'", shellescape("te\nxt"))
|
||||||
call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
|
call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
451,
|
||||||
/**/
|
/**/
|
||||||
450,
|
450,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user