Revision: 1228
http://www.exim.org/viewvc/pcre2?view=rev&revision=1228
Author: ph10
Date: 2020-02-24 17:29:00 +0000 (Mon, 24 Feb 2020)
Log Message:
-----------
Fix bad lookbehind compilation when preceded by a DEFINE group.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_compile.c
code/trunk/testdata/testinput1
code/trunk/testdata/testoutput1
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2020-02-24 16:35:15 UTC (rev 1227)
+++ code/trunk/ChangeLog 2020-02-24 17:29:00 UTC (rev 1228)
@@ -77,7 +77,12 @@
PCRE2_MATCH_INVALID_UTF was set and a match started immediately following the
invalid high surrogate, such as /aa/ matching "\x{d800}aa".
+20. If a DEFINE group immediately preceded a lookbehind assertion, the pattern
+could be mis-compiled and therefore not match correctly. This is the example
+that found this: /(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/ which failed to
+match "word" because the "move back" value was set to zero.
+
Version 10.34 21-November-2019
------------------------------
Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c 2020-02-24 16:35:15 UTC (rev 1227)
+++ code/trunk/src/pcre2_compile.c 2020-02-24 17:29:00 UTC (rev 1228)
@@ -8019,6 +8019,7 @@
lookbehind = *code == OP_ASSERTBACK ||
*code == OP_ASSERTBACK_NOT ||
*code == OP_ASSERTBACK_NA;
+
if (lookbehind)
{
lookbehindlength = META_DATA(pptr[-1]);
@@ -9553,6 +9554,10 @@
break;
case META_COND_DEFINE:
+ pptr += SIZEOFFSET;
+ nestlevel++;
+ break;
+
case META_COND_NAME:
case META_COND_NUMBER:
case META_COND_RNAME:
Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1 2020-02-24 16:35:15 UTC (rev 1227)
+++ code/trunk/testdata/testinput1 2020-02-24 17:29:00 UTC (rev 1228)
@@ -6424,4 +6424,7 @@
"(?<=X(?(DEFINE)(Y))(?1))."
AXYZ
+"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word"
+ word
+
# End of testinput1
Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1 2020-02-24 16:35:15 UTC (rev 1227)
+++ code/trunk/testdata/testoutput1 2020-02-24 17:29:00 UTC (rev 1228)
@@ -10182,4 +10182,8 @@
AXYZ
0: Z
+"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word"
+ word
+ 0: word
+
# End of testinput1