diff --git a/ChangeLog b/ChangeLog index e90806f..4c17626 100644 --- a/ChangeLog +++ b/ChangeLog @@ -43,6 +43,11 @@ path. Also, when a match fails, set the subject field in the match data to NULL for tidiness - none of the substring extractors should reference this after match failure. +11. If a pattern started with a subroutine call that had a quantifier with a +minimum of zero, an incorrect "match must start with this character" could be +recorded. Example: /(?&xxx)*ABC(?XYZ)/ would (incorrectly) expect 'A' to +be the first character of a match. + Version 10.32 10-September-2018 ------------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index c4a515f..83099cf 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -6095,7 +6095,7 @@ for (;; pptr++) } goto GROUP_PROCESS_NOTE_EMPTY; - /* The DEFINE condition is always false. It's internal groups may never + /* The DEFINE condition is always false. Its internal groups may never be called, so matched_char must remain false, hence the jump to GROUP_PROCESS rather than GROUP_PROCESS_NOTE_EMPTY. */ @@ -6435,8 +6435,8 @@ for (;; pptr++) groupnumber = ng->number; /* For a recursion, that's all that is needed. We can now go to - the code above that handles numerical recursion, applying it to - the first group with the given name. */ + the code that handles numerical recursion, applying it to the first + group with the given name. */ if (meta == META_RECURSE_BYNAME) { @@ -7486,6 +7486,8 @@ for (;; pptr++) groupsetfirstcu = FALSE; cb->had_recurse = TRUE; if (firstcuflags == REQ_UNSET) firstcuflags = REQ_NONE; + zerofirstcu = firstcu; + zerofirstcuflags = firstcuflags; break; diff --git a/testdata/testinput1 b/testdata/testinput1 index 84f51e0..3fd5d2a 100644 --- a/testdata/testinput1 +++ b/testdata/testinput1 @@ -6328,4 +6328,19 @@ ef) x/x,mark \= Expect no match aaaa +/ (? \w+ )* \. /xi + pokus. + +/(?(DEFINE) (? \w+ ) ) (?&word)* \./xi + pokus. + +/(?(DEFINE) (? \w+ ) ) ( (?&word)* ) \./xi + pokus. + +/(?&word)* (?(DEFINE) (? \w+ ) ) \./xi + pokus. + +/(?&word)* \. (? \w+ )/xi + pokus.hokus + # End of testinput1 diff --git a/testdata/testoutput1 b/testdata/testoutput1 index 2937ad0..8fd67b3 100644 --- a/testdata/testoutput1 +++ b/testdata/testoutput1 @@ -10025,4 +10025,28 @@ No match aaaa No match +/ (? \w+ )* \. /xi + pokus. + 0: pokus. + 1: pokus + +/(?(DEFINE) (? \w+ ) ) (?&word)* \./xi + pokus. + 0: pokus. + +/(?(DEFINE) (? \w+ ) ) ( (?&word)* ) \./xi + pokus. + 0: pokus. + 1: + 2: pokus + +/(?&word)* (?(DEFINE) (? \w+ ) ) \./xi + pokus. + 0: pokus. + +/(?&word)* \. (? \w+ )/xi + pokus.hokus + 0: pokus.hokus + 1: hokus + # End of testinput1