]> granicus.if.org Git - vim/commitdiff
patch 8.2.3292: underscore in very magic pattern causes a hang v8.2.3292
authorChristian Brabandt <cb@256bit.org>
Thu, 5 Aug 2021 13:24:59 +0000 (15:24 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 5 Aug 2021 13:24:59 +0000 (15:24 +0200)
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)

src/search.c
src/testdir/test_search.vim
src/version.c

index 43966511b7f40d95545cd55c554aba0ba354438e..3b6b437c6d30237b316fa17237378e55b5dcfb24 100644 (file)
@@ -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;
index 1b16207b4ae317fe278df56d581d50b6032f239b..dd47f4f4e48cd635cccd7526493e25d7af1baee4 100644 (file)
@@ -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
index b88b7503ac46fc138f6601127b2c7e09ee42c0f0..4ad59790cc4629f01d4dcacc7e07edf5917ff4a7 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3292,
 /**/
     3291,
 /**/