From 2821076981bfec80414c5e513383f06f1095d769 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Sun, 23 Oct 2016 17:05:09 +0000 Subject: [PATCH] Diagnose an overall recursion (?0) inside a lookbehind as an error. --- ChangeLog | 3 +++ src/pcre2_compile.c | 3 ++- testdata/testinput2 | 2 ++ testdata/testoutput2 | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 53d8afe..422245c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -96,6 +96,9 @@ only when PCRE2_NO_START_OPTIMIZE was *not* set: 16. The "offset" modifier in pcre2test was not being ignored (as documented) when the POSIX API was in use. +17. An overall recursion such as (?0) inside a lookbehind assertion was not +being diagnosed as an error. + Version 10.22 29-July-2016 -------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index ff4972a..8bb4251 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -8497,12 +8497,13 @@ for (;; pptr++) *errcodeptr = ERR15; /* Non-existent subpattern */ return -1; } - + if (group == 0) goto ISNOTFIXED; /* Local recursion */ for (gptr = cb->parsed_pattern; *gptr != META_END; gptr++) { if (META_CODE(*gptr) == META_BIGVALUE) gptr++; else if (*gptr == (META_CAPTURE | group)) break; } + gptrend = parsed_skip(gptr, PSKIP_KET); if (pptr > gptr && pptr < gptrend) goto ISNOTFIXED; /* Local recursion */ for (r = recurses; r != NULL; r = r->prev) if (r->groupptr == gptr) break; diff --git a/testdata/testinput2 b/testdata/testinput2 index 3a81dc0..ba7df01 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4894,4 +4894,6 @@ a)"xI /(?=.*[A-Z])/I +/()(?<=(?0))/ + # End of testinput2 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index ccdb5ef..697cab3 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -15338,6 +15338,9 @@ Capturing subpattern count = 0 May match empty string Subject length lower bound = 0 +/()(?<=(?0))/ +Failed: error 125 at offset 2: lookbehind assertion is not fixed length + # End of testinput2 Error -63: PCRE2_ERROR_BADDATA (unknown error number) Error -62: bad serialized data