From 72542e3c1950ca774b6c8098fb59cac238f9ee6c Mon Sep 17 00:00:00 2001 From: ph10 Date: Tue, 27 Nov 2018 16:00:58 +0000 Subject: [PATCH] Fix non-recognition of anchoring when preceded by (*MARK) etc. --- ChangeLog | 3 +++ src/pcre2_compile.c | 16 ++++++++++++---- testdata/testinput2 | 6 ++++++ testdata/testoutput2 | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1256041..6411b12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -85,6 +85,9 @@ via a string callout. 21. Improve MAP_JIT flag usage on MacOS. Patch by Rich Siegel. +22. If a pattern started with (*MARK), (*COMMIT), (*PRUNE), (*SKIP), or (*THEN) +followed by ^ it was not recognized as anchored. + Version 10.32 10-September-2018 ------------------------------- diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index bad02a6..95ffeba 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -4615,6 +4615,14 @@ for (;;) code += GET(code, 1) + 1 + LINK_SIZE; break; + case OP_MARK: + case OP_COMMIT_ARG: + case OP_PRUNE_ARG: + case OP_SKIP_ARG: + case OP_THEN_ARG: + code += code[1] + PRIV(OP_lengths)[*code]; + break; + default: return code; } @@ -7486,7 +7494,7 @@ for (;; pptr++) cb->had_recurse = TRUE; if (firstcuflags == REQ_UNSET) firstcuflags = REQ_NONE; zerofirstcu = firstcu; - zerofirstcuflags = firstcuflags; + zerofirstcuflags = firstcuflags; break; @@ -8641,7 +8649,7 @@ for (;; pptr++) case META_LOOKBEHIND: case META_LOOKBEHINDNOT: case META_NOCAPTURE: - case META_SCRIPT_RUN: + case META_SCRIPT_RUN: nestlevel++; break; @@ -9054,7 +9062,7 @@ for (;; pptr++) case META_ATOMIC: case META_NOCAPTURE: - case META_SCRIPT_RUN: + case META_SCRIPT_RUN: pptr++; CHECK_GROUP: grouplength = get_grouplength(&pptr, TRUE, errcodeptr, lcptr, group, @@ -9234,7 +9242,7 @@ for (pptr = cb->parsed_pattern; *pptr != META_END; pptr++) case META_QUERY_QUERY: case META_RANGE_ESCAPED: case META_RANGE_LITERAL: - case META_SCRIPT_RUN: + case META_SCRIPT_RUN: case META_SKIP: case META_THEN: break; diff --git a/testdata/testinput2 b/testdata/testinput2 index c9a8b9f..d471284 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -5553,4 +5553,10 @@ a)"xI /foobar/g the foobar thing foobar again\=copy_matched_subject +/(*:XX)^abc/I + +/(*COMMIT:XX)^abc/I + +/(*ACCEPT:XX)^abc/I + # End of testinput2 diff --git a/testdata/testoutput2 b/testdata/testoutput2 index 833ccbd..47eabf3 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -16875,6 +16875,24 @@ Failed: error 128 at offset 14: assertion expected after (?( or (?(?C) 0: foobar 0: foobar +/(*:XX)^abc/I +Capturing subpattern count = 0 +Compile options: +Overall options: anchored +First code unit = 'a' +Subject length lower bound = 3 + +/(*COMMIT:XX)^abc/I +Capturing subpattern count = 0 +Compile options: +Overall options: anchored +First code unit = 'a' +Subject length lower bound = 3 + +/(*ACCEPT:XX)^abc/I +Capturing subpattern count = 0 +Subject length lower bound = 0 + # End of testinput2 Error -70: PCRE2_ERROR_BADDATA (unknown error number) Error -62: bad serialized data