diff options
author | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2020-02-24 17:29:00 +0000 |
---|---|---|
committer | ph10 <ph10@6239d852-aaf2-0410-a92c-79f79f948069> | 2020-02-24 17:29:00 +0000 |
commit | 2e54eab2c5b90d1e798b7de68651d5428c782b70 (patch) | |
tree | 25cfdc63d55bdfbf00c9f3b156fcecf09e349435 | |
parent | d902bb8b5bded98a5b7d48dfee158edd44b9ea5a (diff) | |
download | pcre2-2e54eab2c5b90d1e798b7de68651d5428c782b70.tar.gz |
Fix bad lookbehind compilation when preceded by a DEFINE group.
git-svn-id: svn://vcs.exim.org/pcre2/code/trunk@1228 6239d852-aaf2-0410-a92c-79f79f948069
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/pcre2_compile.c | 5 | ||||
-rw-r--r-- | testdata/testinput1 | 3 | ||||
-rw-r--r-- | testdata/testoutput1 | 4 |
4 files changed, 17 insertions, 0 deletions
@@ -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 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 ------------------------------ diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 515f2aa..13769a0 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -8019,6 +8019,7 @@ and skip over the pattern offset. */ lookbehind = *code == OP_ASSERTBACK || *code == OP_ASSERTBACK_NOT || *code == OP_ASSERTBACK_NA; + if (lookbehind) { lookbehindlength = META_DATA(pptr[-1]); @@ -9553,6 +9554,10 @@ for (; *pptr != META_END; pptr++) break; case META_COND_DEFINE: + pptr += SIZEOFFSET; + nestlevel++; + break; + case META_COND_NAME: case META_COND_NUMBER: case META_COND_RNAME: diff --git a/testdata/testinput1 b/testdata/testinput1 index c6b3647..8d952e2 100644 --- a/testdata/testinput1 +++ b/testdata/testinput1 @@ -6424,4 +6424,7 @@ ef) x/x,mark "(?<=X(?(DEFINE)(Y))(?1))." AXYZ +"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word" + word + # End of testinput1 diff --git a/testdata/testoutput1 b/testdata/testoutput1 index 4c43caa..470e412 100644 --- a/testdata/testoutput1 +++ b/testdata/testoutput1 @@ -10182,4 +10182,8 @@ No match AXYZ 0: Z +"(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word" + word + 0: word + # End of testinput1 |