diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-12-27 17:32:22 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-12-27 17:32:22 +0000 |
commit | 79880968a01921b9884edf78c1bd6144ec0d01ad (patch) | |
tree | b56b3ce4f88a104b7c75ce7abe03c6539c1daacb | |
parent | 50ff7a0c78767ca9035827392c9203911a18d325 (diff) | |
download | pcre-79880968a01921b9884edf78c1bd6144ec0d01ad.tar.gz |
Fix back references with zero minimum repeat when the reference is unset.
git-svn-id: svn://vcs.exim.org/pcre/code/branches/pcre16@832 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | pcre_exec.c | 6 | ||||
-rw-r--r-- | testdata/testinput1 | 6 | ||||
-rw-r--r-- | testdata/testoutput1 | 10 |
4 files changed, 27 insertions, 2 deletions
@@ -1,7 +1,7 @@ ChangeLog for PCRE ------------------ -Version 8.22 +Version 8.30 ------------ 1. Renamed "isnumber" as "is_a_number" because in some Mac environments this @@ -17,6 +17,11 @@ Version 8.22 match a (*MARK), and the match failed at the start of the subject, a reference to memory before the start of the subject could occur. This bug was introduced by fix 17 of release 8.21. + +5. A reference to an unset group with zero minimum repetition was giving + totally wrong answers (in non-JavaScript-compatibility mode). For example, + /(another)?(\1?)test/ matched against "hello world test". This bug was + introduced in release 8.13. Version 8.21 12-Dec-2011 diff --git a/pcre_exec.c b/pcre_exec.c index 768b7dc..d89f36c 100644 --- a/pcre_exec.c +++ b/pcre_exec.c @@ -2630,9 +2630,13 @@ for (;;) } /* Handle repeated back references. If the length of the reference is - zero, just continue with the main loop. */ + zero, just continue with the main loop. If the length is negative, it + means the reference is unset in non-Java-compatible mode. If the minimum is + zero, we can continue at the same level without recursion. For any other + minimum, carrying on will result in NOMATCH. */ if (length == 0) continue; + if (length < 0 && min == 0) continue; /* First, ensure the minimum number of matches are present. We get back the length of the reference string explicitly rather than passing the diff --git a/testdata/testinput1 b/testdata/testinput1 index 9bc9b51..e0529e3 100644 --- a/testdata/testinput1 +++ b/testdata/testinput1 @@ -5244,4 +5244,10 @@ name were given. ---/ ** Failers abpq +/(another)?(\1?)test/ + hello world test + +/(another)?(\1+)test/ + hello world test + /-- End of testinput1 --/ diff --git a/testdata/testoutput1 b/testdata/testoutput1 index 49b4a18..4893e69 100644 --- a/testdata/testoutput1 +++ b/testdata/testoutput1 @@ -8705,4 +8705,14 @@ No match abpq No match +/(another)?(\1?)test/ + hello world test + 0: test + 1: <unset> + 2: + +/(another)?(\1+)test/ + hello world test +No match + /-- End of testinput1 --/ |