Skip to content

Commit 7554da4

Browse files
committed
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)
1 parent 031cb74 commit 7554da4

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/option.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,11 @@ struct vimoption
452452
#define P_NFNAME 0x400000L /* only normal file name chars allowed */
453453
#define P_INSECURE 0x800000L /* option was set from a modeline */
454454
#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
455-
side effects) */
455+
side effects) */
456456
#define P_NO_ML 0x2000000L /* not allowed in modeline */
457457
#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
458458
* there is a redraw flag */
459+
#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
459460

460461
#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
461462

@@ -992,7 +993,7 @@ static struct vimoption options[] =
992993
(char_u *)NULL, PV_NONE,
993994
#endif
994995
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
995-
{"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NFNAME,
996+
{"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
996997
#ifdef FEAT_INS_EXPAND
997998
(char_u *)&p_dict, PV_DICT,
998999
#else
@@ -5876,11 +5877,13 @@ did_set_string_option(
58765877
errmsg = e_secure;
58775878
}
58785879

5879-
/* Check for a "normal" file name in some options. Disallow a path
5880-
* separator (slash and/or backslash), wildcards and characters that are
5881-
* often illegal in a file name. */
5882-
else if ((options[opt_idx].flags & P_NFNAME)
5880+
/* Check for a "normal" directory or file name in some options. Disallow a
5881+
* path separator (slash and/or backslash), wildcards and characters that
5882+
* are often illegal in a file name. */
5883+
else if (((options[opt_idx].flags & P_NFNAME)
58835884
&& vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)
5885+
|| ((options[opt_idx].flags & P_NDNAME)
5886+
&& vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
58845887
{
58855888
errmsg = e_invarg;
58865889
}

src/testdir/test_options.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,18 @@ func Test_keymap_valid()
106106
call assert_fails(":set kmp=trunc\x00name", "E544:")
107107
call assert_fails(":set kmp=trunc\x00name", "trunc")
108108
endfunc
109+
110+
func Test_dictionary()
111+
" Check that it's possible to set the option.
112+
set dictionary=/usr/share/dict/words
113+
call assert_equal('/usr/share/dict/words', &dictionary)
114+
set dictionary=/usr/share/dict/words,/and/there
115+
call assert_equal('/usr/share/dict/words,/and/there', &dictionary)
116+
set dictionary=/usr/share/dict\ words
117+
call assert_equal('/usr/share/dict words', &dictionary)
118+
119+
" Check rejecting weird characters.
120+
call assert_fails("set dictionary=/not&there", "E474:")
121+
call assert_fails("set dictionary=/not>there", "E474:")
122+
call assert_fails("set dictionary=/not.*there", "E474:")
123+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
102,
767769
/**/
768770
101,
769771
/**/

0 commit comments

Comments
 (0)