summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2018-10-20 09:38:44 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2018-10-20 09:38:44 +0000
commita65e1b693110caa27fe8f724583fc28ce5924026 (patch)
tree43bebd0584fe63ba1171ecf1e73a7f749a7ba268
parent1aa76cb33f04fcea3127a0859450e5d18369e5e2 (diff)
downloadpcre-a65e1b693110caa27fe8f724583fc28ce5924026.tar.gz
Fix zero-repeat leading subroutine call first character error.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1741 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog5
-rw-r--r--pcre_compile.c2
-rw-r--r--testdata/testinput115
-rw-r--r--testdata/testoutput124
4 files changed, 46 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9bfbc9b..17fe021 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -40,6 +40,11 @@ such as /(?(1)^())b/ or /(?(?=^))b/.
7. Fix subject buffer overread in JIT when UTF is disabled and \X or \R has
a greater than 1 fixed quantifier. This issue was found by Yunho Kim.
+8. 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(?<xxx>XYZ)/ would (incorrectly) expect 'A' to
+be the first character of a match.
+
Version 8.42 20-March-2018
--------------------------
diff --git a/pcre_compile.c b/pcre_compile.c
index 6141fb3..079d30a 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -7642,6 +7642,8 @@ for (;; ptr++)
/* Can't determine a first byte now */
if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
+ zerofirstchar = firstchar;
+ zerofirstcharflags = firstcharflags;
continue;
diff --git a/testdata/testinput1 b/testdata/testinput1
index 5c23f41..02e4f48 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -5742,4 +5742,19 @@ AbcdCBefgBhiBqz
/X+(?#comment)?/
>XXX<
+/ (?<word> \w+ )* \. /xi
+ pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
+ pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
+ pokus.
+
+/(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
+ pokus.
+
+/(?&word)* \. (?<word> \w+ )/xi
+ pokus.hokus
+
/-- End of testinput1 --/
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index eff8ecc..e6147e6 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -9446,4 +9446,28 @@ No match
>XXX<
0: X
+/ (?<word> \w+ )* \. /xi
+ pokus.
+ 0: pokus.
+ 1: pokus
+
+/(?(DEFINE) (?<word> \w+ ) ) (?&word)* \./xi
+ pokus.
+ 0: pokus.
+
+/(?(DEFINE) (?<word> \w+ ) ) ( (?&word)* ) \./xi
+ pokus.
+ 0: pokus.
+ 1: <unset>
+ 2: pokus
+
+/(?&word)* (?(DEFINE) (?<word> \w+ ) ) \./xi
+ pokus.
+ 0: pokus.
+
+/(?&word)* \. (?<word> \w+ )/xi
+ pokus.hokus
+ 0: pokus.hokus
+ 1: hokus
+
/-- End of testinput1 --/