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 vim/vim#1279, closes vim/vim#1284)

7554da4033
This commit is contained in:
ckelsel
2017-09-24 11:54:40 +08:00
parent d2eba872fb
commit cd13c24427
5 changed files with 27 additions and 8 deletions

View File

@@ -74,6 +74,7 @@ local get_flags = function(o)
{'gettext'},
{'noglob'},
{'normal_fname_chars', 'P_NFNAME'},
{'normal_dname_chars', 'P_NDNAME'},
{'pri_mkrc'},
{'deny_in_modelines', 'P_NO_ML'},
{'deny_duplicates', 'P_NODUP'},

View File

@@ -242,6 +242,7 @@ typedef struct vimoption {
#define P_NO_DEF_EXP 0x8000000U ///< Do not expand default value.
#define P_RWINONLY 0x10000000U ///< only redraw current window
#define P_NDNAME 0x20000000U ///< only normal dir name chars allowed
#define HIGHLIGHT_INIT \
"8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText," \
@@ -2454,11 +2455,13 @@ did_set_string_option (
if ((secure || sandbox != 0)
&& (options[opt_idx].flags & P_SECURE)) {
errmsg = e_secure;
} else if ((options[opt_idx].flags & P_NFNAME)
&& vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL) {
// Check for a "normal" file name in some options. Disallow a path
// separator (slash and/or backslash), wildcards and characters that are
// often illegal in a file name.
} else if ((((options[opt_idx].flags & P_NFNAME)
&& vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL))
|| ((options[opt_idx].flags & P_NDNAME)
&& vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) {
// Check for a "normal" directory or file name in some options. Disallow a
// path separator (slash and/or backslash), wildcards and characters that
// are often illegal in a file name.
errmsg = e_invarg;
}
/* 'backupcopy' */

View File

@@ -7,7 +7,7 @@
-- enable_if=nil,
-- defaults={condition=nil, if_true={vi=224, vim=0}, if_false=nil},
-- secure=nil, gettext=nil, noglob=nil, normal_fname_chars=nil,
-- pri_mkrc=nil, deny_in_modelines=nil,
-- pri_mkrc=nil, deny_in_modelines=nil, normal_dname_chars=nil,
-- expand=nil, nodefault=nil, no_mkrc=nil, vi_def=true, vim=true,
-- alloced=nil,
-- save_pv_indir=nil,
@@ -575,7 +575,7 @@ return {
full_name='dictionary', abbreviation='dict',
type='string', list='onecomma', scope={'global', 'buffer'},
deny_duplicates=true,
normal_fname_chars=true,
normal_dname_chars=true,
vi_def=true,
expand=true,
varname='p_dict',

View File

@@ -103,3 +103,18 @@ func Test_keymap_valid()
call assert_fails(":set kmp=trunc\x00name", "E544:")
call assert_fails(":set kmp=trunc\x00name", "trunc")
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

View File

@@ -850,7 +850,7 @@ static const int included_patches[] = {
// 105 NA
// 104,
// 103 NA
// 102,
102,
101,
100,
99,