diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2017-02-20 17:45:21 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2017-02-20 17:45:21 +0000 |
commit | 63f1aabcabdc7ace28c649657fe2a4f880a87c5a (patch) | |
tree | 56ec118c6068fd3e2145ce8d98c0a10b0482b892 | |
parent | be08075b6ecdd32b061655b567601ea30dd3c2be (diff) | |
download | pcre-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-- | ChangeLog | 3 | ||||
-rw-r--r-- | pcre_compile.c | 15 | ||||
-rw-r--r-- | testdata/testinput1 | 3 | ||||
-rw-r--r-- | testdata/testoutput1 | 4 |
4 files changed, 25 insertions, 0 deletions
@@ -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 --/ |