# HG changeset patch # User Bram Moolenaar # Date 1639842303 -3600 # Node ID c75f70257cf5323e8a267f76b7ff099e67aff3ba # Parent d324ddf0917242cee084ce9b49c05273f6c5c28d patch 8.2.3846: no error when using control character for 'lcs' or 'fcs' Commit: https://github.com/vim/vim/commit/60618c8f1a7ea55452837a446525272142286471 Author: zeertzjq Date: Sat Dec 18 15:32:46 2021 +0000 patch 8.2.3846: no error when using control character for 'lcs' or 'fcs' Problem: No error when using control character for 'lcs' or 'fcs'. Solution: Use char2cells() to check the width. (closes https://github.com/vim/vim/issues/9369) diff --git a/src/screen.c b/src/screen.c --- a/src/screen.c +++ b/src/screen.c @@ -4914,19 +4914,19 @@ set_chars_option(win_T *wp, char_u **var c2 = c3 = 0; s = p + len + 1; c1 = get_encoded_char_adv(&s); - if (mb_char2cells(c1) > 1) + if (char2cells(c1) > 1) return e_invarg; if (tab[i].cp == &lcs_chars.tab2) { if (*s == NUL) return e_invarg; c2 = get_encoded_char_adv(&s); - if (mb_char2cells(c2) > 1) + if (char2cells(c2) > 1) return e_invarg; if (!(*s == ',' || *s == NUL)) { c3 = get_encoded_char_adv(&s); - if (mb_char2cells(c3) > 1) + if (char2cells(c3) > 1) return e_invarg; } } @@ -4968,7 +4968,7 @@ set_chars_option(win_T *wp, char_u **var while (*s != NUL && *s != ',') { c1 = get_encoded_char_adv(&s); - if (mb_char2cells(c1) > 1) + if (char2cells(c1) > 1) return e_invarg; ++multispace_len; } diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim --- a/src/testdir/test_display.vim +++ b/src/testdir/test_display.vim @@ -266,6 +266,8 @@ func Test_eob_fillchars() call assert_fails(':set fillchars=eob:xy', 'E474:') call assert_fails(':set fillchars=eob:\255', 'E474:') call assert_fails(':set fillchars=eob:', 'E474:') + call assert_fails(":set fillchars=eob:\x01", 'E474:') + call assert_fails(':set fillchars=eob:\\x01', 'E474:') " default is ~ new redraw diff --git a/src/testdir/test_listchars.vim b/src/testdir/test_listchars.vim --- a/src/testdir/test_listchars.vim +++ b/src/testdir/test_listchars.vim @@ -333,7 +333,7 @@ func Test_listchars_invalid() call assert_fails('set listchars=space:xx', 'E474:') call assert_fails('set listchars=tab:xxxx', 'E474:') - " Has non-single width character + " Has double-width character call assert_fails('set listchars=space:·', 'E474:') call assert_fails('set listchars=tab:·x', 'E474:') call assert_fails('set listchars=tab:x·', 'E474:') @@ -341,6 +341,20 @@ func Test_listchars_invalid() call assert_fails('set listchars=multispace:·', 'E474:') call assert_fails('set listchars=multispace:xxx·', 'E474:') + " Has control character + call assert_fails("set listchars=space:\x01", 'E474:') + call assert_fails("set listchars=tab:\x01x", 'E474:') + call assert_fails("set listchars=tab:x\x01", 'E474:') + call assert_fails("set listchars=tab:xx\x01", 'E474:') + call assert_fails("set listchars=multispace:\x01", 'E474:') + call assert_fails("set listchars=multispace:xxx\x01", 'E474:') + call assert_fails('set listchars=space:\\x01', 'E474:') + call assert_fails('set listchars=tab:\\x01x', 'E474:') + call assert_fails('set listchars=tab:x\\x01', 'E474:') + call assert_fails('set listchars=tab:xx\\x01', 'E474:') + call assert_fails('set listchars=multispace:\\x01', 'E474:') + call assert_fails('set listchars=multispace:xxx\\x01', 'E474:') + enew! set ambiwidth& listchars& ff& endfunction diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3846, +/**/ 3845, /**/ 3844,