From 24c62fc0d036f933a231be3ba3382344c03cc1e2 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Tue, 23 Jul 2019 16:58:57 +0000 Subject: [PATCH] (*ACCEPT) at start of branch was not recording "may match empty string". --- ChangeLog | 3 +++ src/pcre2_compile.c | 5 +++-- testdata/testoutput2 | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67620a8..dea4a87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -110,6 +110,9 @@ within it, the nested lookbehind was not correctly processed. For example, if (c) An empty string partial hard match can be returned for \z and \Z as it is documented that they shouldn't match. + +22. A branch that started with (*ACCEPT) was not being recognized as one that +could match an empty string. Version 10.33 16-April-2019 diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 466f9c7..d5aa1af 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -5302,6 +5302,7 @@ PCRE2_UCHAR *tempcode; PCRE2_UCHAR *previous = NULL; PCRE2_UCHAR op_previous; BOOL groupsetfirstcu = FALSE; +BOOL had_accept = FALSE; BOOL matched_char = FALSE; BOOL previous_matched_char = FALSE; const uint8_t *cbits = cb->cbits; @@ -5436,7 +5437,7 @@ for (;; pptr++) if (meta < META_ASTERISK || meta > META_MINMAX_QUERY) { previous = code; - if (matched_char) okreturn = 1; + if (matched_char && !had_accept) okreturn = 1; } previous_matched_char = matched_char; @@ -6075,7 +6076,7 @@ for (;; pptr++) workspace overflow. Do not set firstcu after *ACCEPT. */ case META_ACCEPT: - cb->had_accept = TRUE; + cb->had_accept = had_accept = TRUE; for (oc = cb->open_caps; oc != NULL && oc->assert_depth >= cb->assert_depth; oc = oc->next) diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 2fcdac6..5fb1d7f 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -11241,6 +11241,7 @@ No match /(*ACCEPT)a/I,aftertext Capture group count = 0 +May match empty string Subject length lower bound = 0 bax 0: @@ -16911,6 +16912,7 @@ Subject length lower bound = 3 /(*ACCEPT:XX)^abc/I Capture group count = 0 +May match empty string Subject length lower bound = 0 /abc/replace=xyz