forked from aniani/vim
patch 8.0.0102
Problem: Cannot set 'dictionary' to a path.
Solution: Allow for slash and backslash. Add a test (partly by Daisuke
Suzuki, closes #1279, closes #1284)
This commit is contained in:
13
src/option.c
13
src/option.c
@@ -456,6 +456,7 @@ struct vimoption
|
|||||||
#define P_NO_ML 0x2000000L /* not allowed in modeline */
|
#define P_NO_ML 0x2000000L /* not allowed in modeline */
|
||||||
#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
|
#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
|
||||||
* there is a redraw flag */
|
* there is a redraw flag */
|
||||||
|
#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
|
||||||
|
|
||||||
#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
|
#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
|
||||||
|
|
||||||
@@ -992,7 +993,7 @@ static struct vimoption options[] =
|
|||||||
(char_u *)NULL, PV_NONE,
|
(char_u *)NULL, PV_NONE,
|
||||||
#endif
|
#endif
|
||||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||||
{"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NFNAME,
|
{"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
|
||||||
#ifdef FEAT_INS_EXPAND
|
#ifdef FEAT_INS_EXPAND
|
||||||
(char_u *)&p_dict, PV_DICT,
|
(char_u *)&p_dict, PV_DICT,
|
||||||
#else
|
#else
|
||||||
@@ -5876,11 +5877,13 @@ did_set_string_option(
|
|||||||
errmsg = e_secure;
|
errmsg = e_secure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a "normal" file name in some options. Disallow a path
|
/* Check for a "normal" directory or file name in some options. Disallow a
|
||||||
* separator (slash and/or backslash), wildcards and characters that are
|
* path separator (slash and/or backslash), wildcards and characters that
|
||||||
* often illegal in a file name. */
|
* are often illegal in a file name. */
|
||||||
else if ((options[opt_idx].flags & P_NFNAME)
|
else if (((options[opt_idx].flags & P_NFNAME)
|
||||||
&& vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)
|
&& vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)
|
||||||
|
|| ((options[opt_idx].flags & P_NDNAME)
|
||||||
|
&& vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
|
||||||
{
|
{
|
||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,3 +106,18 @@ func Test_keymap_valid()
|
|||||||
call assert_fails(":set kmp=trunc\x00name", "E544:")
|
call assert_fails(":set kmp=trunc\x00name", "E544:")
|
||||||
call assert_fails(":set kmp=trunc\x00name", "trunc")
|
call assert_fails(":set kmp=trunc\x00name", "trunc")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_dictionary()
|
||||||
|
" Check that it's possible to set the option.
|
||||||
|
set dictionary=/usr/share/dict/words
|
||||||
|
call assert_equal('/usr/share/dict/words', &dictionary)
|
||||||
|
set dictionary=/usr/share/dict/words,/and/there
|
||||||
|
call assert_equal('/usr/share/dict/words,/and/there', &dictionary)
|
||||||
|
set dictionary=/usr/share/dict\ words
|
||||||
|
call assert_equal('/usr/share/dict words', &dictionary)
|
||||||
|
|
||||||
|
" Check rejecting weird characters.
|
||||||
|
call assert_fails("set dictionary=/not&there", "E474:")
|
||||||
|
call assert_fails("set dictionary=/not>there", "E474:")
|
||||||
|
call assert_fails("set dictionary=/not.*there", "E474:")
|
||||||
|
endfunc
|
||||||
|
|||||||
@@ -764,6 +764,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 */
|
||||||
|
/**/
|
||||||
|
102,
|
||||||
/**/
|
/**/
|
||||||
101,
|
101,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user