diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2017-12-12 15:07:18 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2017-12-12 15:07:18 +0000 |
commit | 774be03b760cb4b56abf686f6dc56ac4de07fa67 (patch) | |
tree | ad6c84c42f028bd46a9fc7e8d0d7b335f61b45c3 | |
parent | faeb061701c6875684eccc463b1a325e6c9a31af (diff) | |
download | pcre-774be03b760cb4b56abf686f6dc56ac4de07fa67.tar.gz |
Fix wrong first character when a backreference with a zero repeat is first
(apart from assersions) in a pattern.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1719 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pcre_compile.c | 2 | ||||
-rw-r--r-- | testdata/testinput2 | 8 | ||||
-rw-r--r-- | testdata/testoutput2 | 16 |
4 files changed, 30 insertions, 1 deletions
@@ -31,6 +31,11 @@ were all int variables, causing overflow when files with more than 2147483647 lines were processed (assuming 32-bit ints). They have all been changed to unsigned long ints. +7. If a backreference with a minimum repeat count of zero was first in a +pattern, apart from assertions, an incorrect first matching character could be +recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set +as the first character of a match. + Version 8.41 05-July-2017 ------------------------- diff --git a/pcre_compile.c b/pcre_compile.c index 42f204c..6dd8886 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -8060,7 +8060,7 @@ for (;; ptr++) single group (i.e. not to a duplicated name. */ HANDLE_REFERENCE: - if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE; + if (firstcharflags == REQ_UNSET) zerofirstcharflags = firstcharflags = REQ_NONE; previous = code; item_hwm_offset = cd->hwm - cd->start_workspace; *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF; diff --git a/testdata/testinput2 b/testdata/testinput2 index 08c6f39..8ba4dc4 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -4249,4 +4249,12 @@ backtracking verbs. --/ /(?=.*[A-Z])/I +"(?<=(a))\1?b" + ab + aaab + +"(?=(a))\1?b" + ab + aaab + /-- End of testinput2 --/ diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 811bbef..61ed8d9 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -14705,4 +14705,20 @@ No options No first char No need char +"(?<=(a))\1?b" + ab + 0: b + 1: a + aaab + 0: ab + 1: a + +"(?=(a))\1?b" + ab + 0: ab + 1: a + aaab + 0: ab + 1: a + /-- End of testinput2 --/ |