diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-04-04 18:32:32 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-04 18:32:32 +0100 |
commit | 91ff3d4f52a55a7c37a52aaad524cd9dd12efae4 (patch) | |
tree | c07ec4757a25bbbd1357c7c85b8506eab9751006 | |
parent | e8a4c0d91f89544e4f94b7bd612b5fb780944c33 (diff) | |
download | vim-git-91ff3d4f52a55a7c37a52aaad524cd9dd12efae4.tar.gz |
patch 8.2.4688: new regexp engine does not give an error for "\%v"v8.2.4688
Problem: New regexp engine does not give an error for "\%v".
Solution: Check for a value argument. (issue #10079)
-rw-r--r-- | src/errors.h | 4 | ||||
-rw-r--r-- | src/regexp_bt.c | 3 | ||||
-rw-r--r-- | src/regexp_nfa.c | 8 | ||||
-rw-r--r-- | src/testdir/test_regexp_latin.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 26 insertions, 3 deletions
diff --git a/src/errors.h b/src/errors.h index 951acabb2..82c585e7e 100644 --- a/src/errors.h +++ b/src/errors.h @@ -3082,7 +3082,7 @@ EXTERN char e_no_white_space_allowed_after_str_str[] EXTERN char e_dot_can_only_be_used_on_dictionary_str[] INIT(= N_("E1203: Dot can only be used on a dictionary: %s")); #endif -EXTERN char e_regexp_number_after_dot_pos_search[] +EXTERN char e_regexp_number_after_dot_pos_search_chr[] INIT(= N_("E1204: No Number allowed after .: '\\%%%c'")); EXTERN char e_no_white_space_allowed_between_option_and[] INIT(= N_("E1205: No white space allowed between option and")); @@ -3256,3 +3256,5 @@ EXTERN char e_compiling_closure_without_context_str[] EXTERN char e_using_type_not_in_script_context_str[] INIT(= N_("E1272: Using type not in a script context: %s")); #endif +EXTERN char e_nfa_regexp_missing_value_in_chr[] + INIT(= N_("E1273: (NFA regexp) missing value in '\\%%%c'")); diff --git a/src/regexp_bt.c b/src/regexp_bt.c index 793faaf6b..0b3487fa0 100644 --- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -1649,7 +1649,8 @@ regatom(int *flagp) { if (cur && n) { - semsg(_(e_regexp_number_after_dot_pos_search), no_Magic(c)); + semsg(_(e_regexp_number_after_dot_pos_search_chr), + no_Magic(c)); rc_did_emsg = TRUE; return NULL; } diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index 503895eed..d658a6bd7 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -1654,7 +1654,7 @@ nfa_regatom(void) if (cur) { - semsg(_(e_regexp_number_after_dot_pos_search), + semsg(_(e_regexp_number_after_dot_pos_search_chr), no_Magic(c)); return FAIL; } @@ -1673,6 +1673,12 @@ nfa_regatom(void) { long_u limit = INT_MAX; + if (!cur && n == 0) + { + semsg(_(e_nfa_regexp_missing_value_in_chr), + no_Magic(c)); + return FAIL; + } if (c == 'l') { if (cur) diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim index fc9c81bfe..dfb367b5f 100644 --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -91,6 +91,18 @@ func Test_multi_failure() set re=0 endfunc +func Test_column_failure() + set re=1 + call assert_fails('/\%v', 'E71:') + call assert_fails('/\%c', 'E71:') + call assert_fails('/\%l', 'E71:') + set re=2 + call assert_fails('/\%v', 'E1273:') + call assert_fails('/\%c', 'E1273:') + call assert_fails('/\%l', 'E1273:') + set re=0 +endfunc + func Test_recursive_addstate() " This will call addstate() recursively until it runs into the limit. let lnum = search('\v((){328}){389}') diff --git a/src/version.c b/src/version.c index 23dede051..9b1d56a04 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4688, +/**/ 4687, /**/ 4686, |