Skip to content

Commit a1f7d77

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents c6a45c3 + 3a39379 commit a1f7d77

File tree

6 files changed

+53
-8
lines changed

6 files changed

+53
-8
lines changed

src/ex_getln.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,8 @@ getcmdline_int(
17861786
// that occurs while typing a command should
17871787
// cause the command not to be executed.
17881788

1789+
got_int = FALSE; // avoid infinite Ctrl-C loop in Ex mode
1790+
17891791
// Trigger SafeState if nothing is pending.
17901792
may_trigger_safestate(xpc.xp_numfiles <= 0);
17911793

src/spellfile.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4371,13 +4371,13 @@ wordtree_alloc(spellinfo_T *spin)
43714371
* Control characters and trailing '/' are invalid. Space is OK.
43724372
*/
43734373
static int
4374-
valid_spell_word(char_u *word)
4374+
valid_spell_word(char_u *word, char_u *end)
43754375
{
43764376
char_u *p;
43774377

4378-
if (enc_utf8 && !utf_valid_string(word, NULL))
4378+
if (enc_utf8 && !utf_valid_string(word, end))
43794379
return FALSE;
4380-
for (p = word; *p != NUL; p += mb_ptr2len(p))
4380+
for (p = word; *p != NUL && p < end; p += mb_ptr2len(p))
43814381
if (*p < ' ' || (p[0] == '/' && p[1] == NUL))
43824382
return FALSE;
43834383
return TRUE;
@@ -4408,7 +4408,7 @@ store_word(
44084408
char_u *p;
44094409

44104410
// Avoid adding illegal bytes to the word tree.
4411-
if (!valid_spell_word(word))
4411+
if (!valid_spell_word(word, word + len))
44124412
return FAIL;
44134413

44144414
(void)spell_casefold(curwin, word, len, foldword, MAXWLEN);
@@ -6211,7 +6211,7 @@ spell_add_word(
62116211
int i;
62126212
char_u *spf;
62136213

6214-
if (!valid_spell_word(word))
6214+
if (!valid_spell_word(word, word + len))
62156215
{
62166216
emsg(_(e_illegal_character_in_word));
62176217
return;

src/testdir/test_ex_mode.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,29 @@ func Test_Ex_global()
145145
bwipe!
146146
endfunc
147147

148+
" Test for pressing Ctrl-C in :append inside a loop in Ex mode
149+
" This used to hang Vim
150+
func Test_Ex_append_in_loop()
151+
CheckRunVimInTerminal
152+
let buf = RunVimInTerminal('', {'rows': 6})
153+
154+
call term_sendkeys(buf, "gQ")
155+
call term_sendkeys(buf, "for i in range(1)\<CR>")
156+
call term_sendkeys(buf, "append\<CR>")
157+
call WaitForAssert({-> assert_match(': append', term_getline(buf, 5))}, 1000)
158+
call term_sendkeys(buf, "\<C-C>")
159+
call term_wait(buf)
160+
call term_sendkeys(buf, "foo\<CR>")
161+
call WaitForAssert({-> assert_match('foo', term_getline(buf, 5))}, 1000)
162+
call term_sendkeys(buf, ".\<CR>")
163+
call WaitForAssert({-> assert_match('.', term_getline(buf, 5))}, 1000)
164+
call term_sendkeys(buf, "endfor\<CR>")
165+
call term_sendkeys(buf, "vi\<CR>")
166+
call WaitForAssert({-> assert_match('foo', term_getline(buf, 1))}, 1000)
167+
168+
call StopVimInTerminal(buf)
169+
endfunc
170+
148171
" In Ex-mode, a backslash escapes a newline
149172
func Test_Ex_escape_enter()
150173
call feedkeys("gQlet l = \"a\\\<kEnter>b\"\<cr>vi\<cr>", 'xt')

src/testdir/test_regexp_latin.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,13 +1101,17 @@ func Test_using_two_engines_pattern()
11011101
call setline(1, ['foobar=0', 'foobar=1', 'foobar=2'])
11021102
" \%#= at the end of the pattern
11031103
for i in range(0, 2)
1104-
call cursor( (i+1), 7)
1105-
call assert_fails("%s/foobar\\%#=" .. i, 'E1281:')
1104+
for j in range(0, 2)
1105+
exe "set re=" .. i
1106+
call cursor(j + 1, 7)
1107+
call assert_fails("%s/foobar\\%#=" .. j, 'E1281:')
1108+
endfor
11061109
endfor
1110+
set re=0
11071111

11081112
" \%#= at the start of the pattern
11091113
for i in range(0, 2)
1110-
call cursor( (i+1), 7)
1114+
call cursor(i + 1, 7)
11111115
exe ":%s/\\%#=" .. i .. "foobar=" .. i .. "/xx"
11121116
endfor
11131117
call assert_equal(['xx', 'xx', 'xx'], getline(1, '$'))

src/testdir/test_spell.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,16 @@ func Test_spell_good_word_invalid()
884884
bwipe!
885885
endfunc
886886

887+
func Test_spell_good_word_slash()
888+
" This caused E1280.
889+
new
890+
norm afoo /
891+
1
892+
norm zG
893+
894+
bwipe!
895+
endfunc
896+
887897
func LoadAffAndDic(aff_contents, dic_contents)
888898
set enc=latin1
889899
set spellfile=

src/version.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,12 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
53,
755+
/**/
756+
52,
757+
/**/
758+
51,
753759
/**/
754760
50,
755761
/**/

0 commit comments

Comments
 (0)