Skip to content

Commit bc67e5a

Browse files
chrisbrabrammool
authored andcommitted
patch 8.2.3292: underscore in very magic pattern causes a hang
Problem: Underscore in very magic pattern causes a hang. Pattern with \V are case sensitive. (Yutao Yuan) Solution: Adjust condition for magicness and advance pointer. (Christian Brabandt, closes #8707, closes #8704, closes #8705)
1 parent 4a01159 commit bc67e5a

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/search.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ pat_has_uppercase(char_u *pat)
445445
return TRUE;
446446
p += l;
447447
}
448-
else if (*p == '\\' && magic_val == MAGIC_ON)
448+
else if (*p == '\\' && magic_val <= MAGIC_ON)
449449
{
450450
if (p[1] == '_' && p[2] != NUL) // skip "\_X"
451451
p += 3;
@@ -460,6 +460,8 @@ pat_has_uppercase(char_u *pat)
460460
{
461461
if (p[1] != NUL) // skip "_X" and %X
462462
p += 2;
463+
else
464+
p++;
463465
}
464466
else if (MB_ISUPPER(*p))
465467
return TRUE;

src/testdir/test_search.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,17 @@ func Test_pattern_is_uppercase_smartcase()
19621962
call assert_equal(['abc', 'ABC', 'Abc', ''],
19631963
\ getline(1, '$'))
19641964

1965+
call setline(1, input)
1966+
call cursor(1,1)
1967+
" \Vabc should match everything
1968+
%s/\Vabc//g
1969+
call assert_equal(['', '', '', ''], getline(1, '$'))
1970+
1971+
call setline(1, input + ['_abc'])
1972+
" _ matches normally
1973+
%s/\v_.*//g
1974+
call assert_equal(['abc', 'ABC', 'Abc', 'abC', ''], getline(1, '$'))
1975+
19651976
set smartcase& ignorecase&
19661977
bw!
19671978
endfunc

src/version.c

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

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3292,
758760
/**/
759761
3291,
760762
/**/

0 commit comments

Comments
 (0)