summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2017-02-20 17:45:21 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2017-02-20 17:45:21 +0000
commit63f1aabcabdc7ace28c649657fe2a4f880a87c5a (patch)
tree56ec118c6068fd3e2145ce8d98c0a10b0482b892
parentbe08075b6ecdd32b061655b567601ea30dd3c2be (diff)
downloadpcre-63f1aabcabdc7ace28c649657fe2a4f880a87c5a.tar.gz
Fix recognition of (?# style comment between quantifier and '+' or '?'.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1682 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog3
-rw-r--r--pcre_compile.c15
-rw-r--r--testdata/testinput13
-rw-r--r--testdata/testoutput14
4 files changed, 25 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d813935..cac3973 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,9 @@ several lines after the start.
3. Fix a missing else in the JIT compiler reported by 'idaifish'.
+4. A (?# style comment is now ignored between a basic quantifier and a
+following '+' or '?' (example: /X+(?#comment)?Y/.
+
Version 8.40 11-January-2017
----------------------------
diff --git a/pcre_compile.c b/pcre_compile.c
index de92313..c787813 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -5739,6 +5739,21 @@ for (;; ptr++)
ptr = p - 1; /* Character before the next significant one. */
}
+ /* We also need to skip over (?# comments, which are not dependent on
+ extended mode. */
+
+ if (ptr[1] == CHAR_LEFT_PARENTHESIS && ptr[2] == CHAR_QUESTION_MARK &&
+ ptr[3] == CHAR_NUMBER_SIGN)
+ {
+ ptr += 4;
+ while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
+ if (*ptr == CHAR_NULL)
+ {
+ *errorcodeptr = ERR18;
+ goto FAILED;
+ }
+ }
+
/* If the next character is '+', we have a possessive quantifier. This
implies greediness, whatever the setting of the PCRE_UNGREEDY option.
If the next character is '?' this is a minimizing repeat, by default,
diff --git a/testdata/testinput1 b/testdata/testinput1
index 93abab3..5c23f41 100644
--- a/testdata/testinput1
+++ b/testdata/testinput1
@@ -5739,4 +5739,7 @@ AbcdCBefgBhiBqz
/(?=.*X)X$/
\ X
+/X+(?#comment)?/
+ >XXX<
+
/-- End of testinput1 --/
diff --git a/testdata/testoutput1 b/testdata/testoutput1
index a2b3cff..eff8ecc 100644
--- a/testdata/testoutput1
+++ b/testdata/testoutput1
@@ -9442,4 +9442,8 @@ No match
\ X
0: X
+/X+(?#comment)?/
+ >XXX<
+ 0: X
+
/-- End of testinput1 --/