From 8a5ce4c055808fd3a19b0da15e0e3caeb0ac3abb Mon Sep 17 00:00:00 2001 From: ph10 Date: Mon, 26 Aug 2019 16:28:26 +0000 Subject: [PATCH] Fix bug introduced in commit 1133. Lookbehinds that follow a condition were not always properly handled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1160 6239d852-aaf2-0410-a92c-79f79f948069 Petr Písař: Ported to 10.33. Signed-off-by: Petr Písař --- src/pcre2_compile.c | 12 +++++- testdata/testinput1 | 3 ++ testdata/testinput2 | 10 +++++ testdata/testoutput1 | 6 +++ testdata/testoutput2 | 93 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 2 deletions(-) diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index b68c154..5cae730 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -9411,13 +9411,22 @@ for (; *pptr != META_END; pptr++) break; case META_BACKREF_BYNAME: + case META_RECURSE_BYNAME: + pptr += 1 + SIZEOFFSET; + break; + case META_COND_DEFINE: case META_COND_NAME: case META_COND_NUMBER: case META_COND_RNAME: case META_COND_RNUMBER: - case META_RECURSE_BYNAME: pptr += 1 + SIZEOFFSET; + nestlevel++; + break; + + case META_COND_VERSION: + pptr += 3; + nestlevel++; break; case META_CALLOUT_STRING: @@ -9438,7 +9447,6 @@ for (; *pptr != META_END; pptr++) break; case META_CALLOUT_NUMBER: - case META_COND_VERSION: pptr += 3; break; diff --git a/testdata/testinput1 b/testdata/testinput1 index ee9354b..db1706b 100644 --- a/testdata/testinput1 +++ b/testdata/testinput1 @@ -6371,4 +6371,7 @@ ef) x/x,mark /(?<=(?=(?<=a)))b/ ab +/^(?a)(?()b)((?<=b).*)$/ + abc + # End of testinput1 diff --git a/testdata/testinput2 b/testdata/testinput2 index 2b1aced..a5f59b9 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -5611,4 +5611,14 @@ a)"xI /\A\s*((?:[^`]{28500}){4}|a)/I a +/(?a)(?()b)((?<=b).*)/B + +/(?(1)b)((?<=b).*)/B + +/(?(R1)b)((?<=b).*)/B + +/(?(DEFINE)b)((?<=b).*)/B + +/(?(VERSION=10.4)b)((?<=b).*)/B + # End of testinput2 diff --git a/testdata/testoutput1 b/testdata/testoutput1 index c9bfea8..3f872e7 100644 --- a/testdata/testoutput1 +++ b/testdata/testoutput1 @@ -10090,4 +10090,10 @@ No match ab 0: b +/^(?a)(?()b)((?<=b).*)$/ + abc + 0: abc + 1: a + 2: c + # End of testinput1 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index d2415c3..6e41ed8 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -16983,6 +16983,99 @@ Subject length lower bound = 1 0: a 1: a +/(?a)(?()b)((?<=b).*)/B +------------------------------------------------------------------ + Bra + CBra 1 + a + Ket + Cond + 1 Cond ref + b + Ket + CBra 2 + AssertB + Reverse + b + Ket + Any*+ + Ket + Ket + End +------------------------------------------------------------------ + +/(?(1)b)((?<=b).*)/B +------------------------------------------------------------------ + Bra + Cond + 1 Cond ref + b + Ket + CBra 1 + AssertB + Reverse + b + Ket + Any*+ + Ket + Ket + End +------------------------------------------------------------------ + +/(?(R1)b)((?<=b).*)/B +------------------------------------------------------------------ + Bra + Cond + Cond recurse 1 + b + Ket + CBra 1 + AssertB + Reverse + b + Ket + Any*+ + Ket + Ket + End +------------------------------------------------------------------ + +/(?(DEFINE)b)((?<=b).*)/B +------------------------------------------------------------------ + Bra + Cond + Cond false + b + Ket + CBra 1 + AssertB + Reverse + b + Ket + Any*+ + Ket + Ket + End +------------------------------------------------------------------ + +/(?(VERSION=10.4)b)((?<=b).*)/B +------------------------------------------------------------------ + Bra + Cond + Cond false + b + Ket + CBra 1 + AssertB + Reverse + b + Ket + Any*+ + Ket + Ket + End +------------------------------------------------------------------ + # End of testinput2 Error -70: PCRE2_ERROR_BADDATA (unknown error number) Error -62: bad serialized data -- 2.21.0