Mercurial > vim
changeset 25511:a6eea433586b v8.2.3292
patch 8.2.3292: underscore in very magic pattern causes a hang
Commit: https://github.com/vim/vim/commit/bc67e5a0a494f5fc48e872d747371e31a782d171
Author: Christian Brabandt <cb@256bit.org>
Date: Thu Aug 5 15:24:59 2021 +0200
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 05 Aug 2021 15:30:04 +0200 |
parents | d390d493f704 |
children | 0aa14b201e89 |
files | src/search.c src/testdir/test_search.vim src/version.c |
diffstat | 3 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/search.c +++ b/src/search.c @@ -445,7 +445,7 @@ pat_has_uppercase(char_u *pat) return TRUE; p += l; } - else if (*p == '\\' && magic_val == MAGIC_ON) + else if (*p == '\\' && magic_val <= MAGIC_ON) { if (p[1] == '_' && p[2] != NUL) // skip "\_X" p += 3; @@ -460,6 +460,8 @@ pat_has_uppercase(char_u *pat) { if (p[1] != NUL) // skip "_X" and %X p += 2; + else + p++; } else if (MB_ISUPPER(*p)) return TRUE;
--- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -1962,6 +1962,17 @@ func Test_pattern_is_uppercase_smartcase call assert_equal(['abc', 'ABC', 'Abc', ''], \ getline(1, '$')) + call setline(1, input) + call cursor(1,1) + " \Vabc should match everything + %s/\Vabc//g + call assert_equal(['', '', '', ''], getline(1, '$')) + + call setline(1, input + ['_abc']) + " _ matches normally + %s/\v_.*//g + call assert_equal(['abc', 'ABC', 'Abc', 'abC', ''], getline(1, '$')) + set smartcase& ignorecase& bw! endfunc