Fix bad lookbehind compilation when preceded by a DEFINE group.
This commit is contained in:
parent
4e8f13cbd6
commit
3be538015b
|
@ -77,6 +77,11 @@ low surrogate. This caused incorrect behaviour, for example when
|
||||||
PCRE2_MATCH_INVALID_UTF was set and a match started immediately following the
|
PCRE2_MATCH_INVALID_UTF was set and a match started immediately following the
|
||||||
invalid high surrogate, such as /aa/ matching "\x{d800}aa".
|
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
|
Version 10.34 21-November-2019
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
|
@ -8019,6 +8019,7 @@ and skip over the pattern offset. */
|
||||||
lookbehind = *code == OP_ASSERTBACK ||
|
lookbehind = *code == OP_ASSERTBACK ||
|
||||||
*code == OP_ASSERTBACK_NOT ||
|
*code == OP_ASSERTBACK_NOT ||
|
||||||
*code == OP_ASSERTBACK_NA;
|
*code == OP_ASSERTBACK_NA;
|
||||||
|
|
||||||
if (lookbehind)
|
if (lookbehind)
|
||||||
{
|
{
|
||||||
lookbehindlength = META_DATA(pptr[-1]);
|
lookbehindlength = META_DATA(pptr[-1]);
|
||||||
|
@ -9553,6 +9554,10 @@ for (; *pptr != META_END; pptr++)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case META_COND_DEFINE:
|
case META_COND_DEFINE:
|
||||||
|
pptr += SIZEOFFSET;
|
||||||
|
nestlevel++;
|
||||||
|
break;
|
||||||
|
|
||||||
case META_COND_NAME:
|
case META_COND_NAME:
|
||||||
case META_COND_NUMBER:
|
case META_COND_NUMBER:
|
||||||
case META_COND_RNAME:
|
case META_COND_RNAME:
|
||||||
|
|
|
@ -6424,4 +6424,7 @@ ef) x/x,mark
|
||||||
"(?<=X(?(DEFINE)(Y))(?1))."
|
"(?<=X(?(DEFINE)(Y))(?1))."
|
||||||
AXYZ
|
AXYZ
|
||||||
|
|
||||||
|
"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word"
|
||||||
|
word
|
||||||
|
|
||||||
# End of testinput1
|
# End of testinput1
|
||||||
|
|
|
@ -10182,4 +10182,8 @@ No match
|
||||||
AXYZ
|
AXYZ
|
||||||
0: Z
|
0: Z
|
||||||
|
|
||||||
|
"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word"
|
||||||
|
word
|
||||||
|
0: word
|
||||||
|
|
||||||
# End of testinput1
|
# End of testinput1
|
||||||
|
|
Loading…
Reference in New Issue