mirror of
https://github.com/vim/vim.git
synced 2025-09-05 21:43:39 -04:00
updated for version 7.3.1295
Problem: glob() and globpath() do not handle escaped special characters properly. Solution: Handle escaped characters differently. (Adnan Zafar)
This commit is contained in:
parent
a87aa8061c
commit
f4e1143697
@ -10301,7 +10301,10 @@ file_pat_to_reg_pat(pat, pat_end, allow_dirs, no_bslash)
|
|||||||
* foo\,bar -> foo,bar
|
* foo\,bar -> foo,bar
|
||||||
* foo\ bar -> foo bar
|
* foo\ bar -> foo bar
|
||||||
* Don't unescape \, * and others that are also special in a
|
* Don't unescape \, * and others that are also special in a
|
||||||
* regexp. */
|
* regexp.
|
||||||
|
* An escaped { must be unescaped since we use magic not
|
||||||
|
* verymagic.
|
||||||
|
*/
|
||||||
if (*++p == '?'
|
if (*++p == '?'
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
&& no_bslash
|
&& no_bslash
|
||||||
@ -10309,7 +10312,8 @@ file_pat_to_reg_pat(pat, pat_end, allow_dirs, no_bslash)
|
|||||||
)
|
)
|
||||||
reg_pat[i++] = '?';
|
reg_pat[i++] = '?';
|
||||||
else
|
else
|
||||||
if (*p == ',' || *p == '%' || *p == '#' || *p == ' ')
|
if (*p == ',' || *p == '%' || *p == '#'
|
||||||
|
|| *p == ' ' || *p == '{')
|
||||||
reg_pat[i++] = *p;
|
reg_pat[i++] = *p;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
54
src/misc1.c
54
src/misc1.c
@ -10457,6 +10457,54 @@ remove_duplicates(gap)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int has_env_var __ARGS((char_u *p));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "p" contains what looks like an environment variable.
|
||||||
|
* Allowing for escaping.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
has_env_var(p)
|
||||||
|
char_u *p;
|
||||||
|
{
|
||||||
|
for ( ; *p; mb_ptr_adv(p))
|
||||||
|
{
|
||||||
|
if (*p == '\\' && p[1] != NUL)
|
||||||
|
++p;
|
||||||
|
else if (vim_strchr((char_u *)
|
||||||
|
#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
|
||||||
|
"$%"
|
||||||
|
#else
|
||||||
|
"$"
|
||||||
|
#endif
|
||||||
|
, *p) != NULL)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef SPECIAL_WILDCHAR
|
||||||
|
static int has_special_wildchar __ARGS((char_u *p));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "p" contains a special wildcard character.
|
||||||
|
* Allowing for escaping.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
has_special_wildchar(p)
|
||||||
|
char_u *p;
|
||||||
|
{
|
||||||
|
for ( ; *p; mb_ptr_adv(p))
|
||||||
|
{
|
||||||
|
if (*p == '\\' && p[1] != NUL)
|
||||||
|
++p;
|
||||||
|
else if (vim_strchr((char_u *)SPECIAL_WILDCHAR, *p) != NULL)
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generic wildcard expansion code.
|
* Generic wildcard expansion code.
|
||||||
*
|
*
|
||||||
@ -10507,7 +10555,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
|
|||||||
*/
|
*/
|
||||||
for (i = 0; i < num_pat; i++)
|
for (i = 0; i < num_pat; i++)
|
||||||
{
|
{
|
||||||
if (vim_strpbrk(pat[i], (char_u *)SPECIAL_WILDCHAR) != NULL
|
if (has_special_wildchar(pat[i])
|
||||||
# ifdef VIM_BACKTICK
|
# ifdef VIM_BACKTICK
|
||||||
&& !(vim_backtick(pat[i]) && pat[i][1] == '=')
|
&& !(vim_backtick(pat[i]) && pat[i][1] == '=')
|
||||||
# endif
|
# endif
|
||||||
@ -10537,7 +10585,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
|
|||||||
/*
|
/*
|
||||||
* First expand environment variables, "~/" and "~user/".
|
* First expand environment variables, "~/" and "~user/".
|
||||||
*/
|
*/
|
||||||
if (vim_strchr(p, '$') != NULL || *p == '~')
|
if (has_env_var(p) || *p == '~')
|
||||||
{
|
{
|
||||||
p = expand_env_save_opt(p, TRUE);
|
p = expand_env_save_opt(p, TRUE);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
@ -10548,7 +10596,7 @@ gen_expand_wildcards(num_pat, pat, num_file, file, flags)
|
|||||||
* variable, use the shell to do that. Discard previously
|
* variable, use the shell to do that. Discard previously
|
||||||
* found file names and start all over again.
|
* found file names and start all over again.
|
||||||
*/
|
*/
|
||||||
else if (vim_strchr(p, '$') != NULL || *p == '~')
|
else if (has_env_var(p) || *p == '~')
|
||||||
{
|
{
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
ga_clear_strings(&ga);
|
ga_clear_strings(&ga);
|
||||||
|
@ -33,7 +33,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
|
|||||||
test76.out test77.out test78.out test79.out test80.out \
|
test76.out test77.out test78.out test79.out test80.out \
|
||||||
test81.out test82.out test83.out test84.out test88.out \
|
test81.out test82.out test83.out test84.out test88.out \
|
||||||
test89.out test90.out test91.out test92.out test93.out \
|
test89.out test90.out test91.out test92.out test93.out \
|
||||||
test94.out test95.out test96.out
|
test94.out test95.out test96.out test97.out
|
||||||
|
|
||||||
.SUFFIXES: .in .out
|
.SUFFIXES: .in .out
|
||||||
|
|
||||||
@ -146,3 +146,4 @@ test93.out: test93.in
|
|||||||
test94.out: test94.in
|
test94.out: test94.in
|
||||||
test95.out: test95.in
|
test95.out: test95.in
|
||||||
test96.out: test96.in
|
test96.out: test96.in
|
||||||
|
test97.out: test97.in
|
||||||
|
@ -32,7 +32,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
|
|||||||
test79.out test80.out test81.out test82.out test83.out \
|
test79.out test80.out test81.out test82.out test83.out \
|
||||||
test84.out test85.out test86.out test87.out test88.out \
|
test84.out test85.out test86.out test87.out test88.out \
|
||||||
test89.out test90.out test91.out test92.out test93.out \
|
test89.out test90.out test91.out test92.out test93.out \
|
||||||
test94.out test95.out test96.out
|
test94.out test95.out test96.out test97.out
|
||||||
|
|
||||||
SCRIPTS32 = test50.out test70.out
|
SCRIPTS32 = test50.out test70.out
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
|
|||||||
test79.out test80.out test81.out test82.out test83.out \
|
test79.out test80.out test81.out test82.out test83.out \
|
||||||
test84.out test85.out test86.out test87.out test88.out \
|
test84.out test85.out test86.out test87.out test88.out \
|
||||||
test89.out test90.out test91.out test92.out test93.out \
|
test89.out test90.out test91.out test92.out test93.out \
|
||||||
test94.out test95.out test96.out
|
test94.out test95.out test96.out test97.out
|
||||||
|
|
||||||
SCRIPTS32 = test50.out test70.out
|
SCRIPTS32 = test50.out test70.out
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
|
|||||||
test76.out test77.out test78.out test79.out test80.out \
|
test76.out test77.out test78.out test79.out test80.out \
|
||||||
test81.out test82.out test83.out test84.out test88.out \
|
test81.out test82.out test83.out test84.out test88.out \
|
||||||
test89.out test90.out test91.out test92.out test93.out \
|
test89.out test90.out test91.out test92.out test93.out \
|
||||||
test94.out test95.out test96.out
|
test94.out test95.out test96.out test97.out
|
||||||
|
|
||||||
.SUFFIXES: .in .out
|
.SUFFIXES: .in .out
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
|
# Authors: Zoltan Arpadffy, <arpadffy@polarhome.com>
|
||||||
# Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
|
# Sandor Kopanyi, <sandor.kopanyi@mailbox.hu>
|
||||||
#
|
#
|
||||||
# Last change: 2013 Jul 01
|
# Last change: 2013 Jul 03
|
||||||
#
|
#
|
||||||
# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
|
# This has been tested on VMS 6.2 to 8.3 on DEC Alpha, VAX and IA64.
|
||||||
# Edit the lines in the Configuration section below to select.
|
# Edit the lines in the Configuration section below to select.
|
||||||
@ -78,7 +78,7 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
|
|||||||
test77.out test78.out test79.out test80.out test81.out \
|
test77.out test78.out test79.out test80.out test81.out \
|
||||||
test82.out test83.out test84.out test88.out test89.out \
|
test82.out test83.out test84.out test88.out test89.out \
|
||||||
test90.out test91.out test92.out test93.out test94.out \
|
test90.out test91.out test92.out test93.out test94.out \
|
||||||
test95.out test96.out
|
test95.out test96.out test97.out
|
||||||
|
|
||||||
# Known problems:
|
# Known problems:
|
||||||
# Test 30: a problem around mac format - unknown reason
|
# Test 30: a problem around mac format - unknown reason
|
||||||
|
@ -29,7 +29,7 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
|
|||||||
test79.out test80.out test81.out test82.out test83.out \
|
test79.out test80.out test81.out test82.out test83.out \
|
||||||
test84.out test85.out test86.out test87.out test88.out \
|
test84.out test85.out test86.out test87.out test88.out \
|
||||||
test89.out test90.out test91.out test92.out test93.out \
|
test89.out test90.out test91.out test92.out test93.out \
|
||||||
test94.out test95.out test96.out
|
test94.out test95.out test96.out test97.out
|
||||||
|
|
||||||
SCRIPTS_GUI = test16.out
|
SCRIPTS_GUI = test16.out
|
||||||
|
|
||||||
|
17
src/testdir/test97.in
Normal file
17
src/testdir/test97.in
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Test whether glob()/globpath() return correct results with certain escaped
|
||||||
|
characters.
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:so small.vim
|
||||||
|
:set shell=doesnotexist
|
||||||
|
:e test.out
|
||||||
|
:put =glob('Xxx\{')
|
||||||
|
:put =glob('Xxx\$')
|
||||||
|
:w! Xxx{
|
||||||
|
:w! Xxx\$
|
||||||
|
:put =glob('Xxx\{')
|
||||||
|
:put =glob('Xxx\$')
|
||||||
|
:w
|
||||||
|
:qa!
|
||||||
|
ENDTEST
|
||||||
|
|
5
src/testdir/test97.ok
Normal file
5
src/testdir/test97.ok
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Xxx{
|
||||||
|
Xxx$
|
@ -728,6 +728,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 */
|
||||||
|
/**/
|
||||||
|
1295,
|
||||||
/**/
|
/**/
|
||||||
1294,
|
1294,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user