mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
vim-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: vim/vim#14876
88c8c547d5
This commit is contained in:
@@ -84,7 +84,7 @@ typedef struct {
|
|||||||
/// Structure containing last search pattern and its attributes.
|
/// Structure containing last search pattern and its attributes.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *pat; ///< The pattern (in allocated memory) or NULL.
|
char *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).
|
||||||
bool magic; ///< Magicness of the pattern.
|
bool magic; ///< Magicness of the pattern.
|
||||||
bool no_scs; ///< No smartcase for this pattern.
|
bool no_scs; ///< No smartcase for this pattern.
|
||||||
Timestamp timestamp; ///< Time of the last change.
|
Timestamp timestamp; ///< Time of the last change.
|
||||||
|
@@ -266,11 +266,11 @@ char *vim_strsave_shellescape(const char *string, bool do_special, bool do_newli
|
|||||||
*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) {
|
||||||
|
@@ -119,6 +119,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))
|
||||||
|
Reference in New Issue
Block a user