summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2021-06-01 14:33:57 +0100
committerHugo van der Sanden <hv@crypt.org>2021-06-01 14:33:57 +0100
commit499aa13271ff03425a8258615a0702c5b830be8b (patch)
tree8b0764f88f574f954d17b92c9128e75d1763f176 /regcomp.c
parent403d7eb3e4320188571cf61b9dab62ff10799f49 (diff)
downloadperl-499aa13271ff03425a8258615a0702c5b830be8b.tar.gz
gh18770: stop scanning for substrs after *COMMIT
*ACCEPT already avoids this (because it is "ENDLIKE"), but gets a related fix to stop scanning for start class.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/regcomp.c b/regcomp.c
index 962f4cb941..e6ca7800c8 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6350,18 +6350,32 @@ Perl_re_printf( aTHX_ "LHS=%" UVuf " RHS=%" UVuf "\n",
*(data->last_closep) = ARG(scan);
}
else if (OP(scan) == EVAL) {
- if (data)
- data->flags |= SF_HAS_EVAL;
+ if (data)
+ data->flags |= SF_HAS_EVAL;
}
else if ( PL_regkind[OP(scan)] == ENDLIKE ) {
if (flags & SCF_DO_SUBSTR) {
scan_commit(pRExC_state, data, minlenp, is_inf);
flags &= ~SCF_DO_SUBSTR;
}
- if (data && OP(scan)==ACCEPT) {
- data->flags |= SCF_SEEN_ACCEPT;
- if (stopmin > min)
- stopmin = min;
+ if (OP(scan)==ACCEPT) {
+ /* m{(*ACCEPT)x} does not have to start with 'x' */
+ flags &= ~SCF_DO_STCLASS;
+ if (data) {
+ data->flags |= SCF_SEEN_ACCEPT;
+ if (stopmin > min)
+ stopmin = min;
+ }
+ }
+ }
+ else if (OP(scan) == COMMIT) {
+ /* gh18770: m{abc(*COMMIT)xyz} must fail on "abc abcxyz", so we
+ * must not end up with "abcxyz" as a fixed substring else we'll
+ * skip straight to attempting to match at offset 4.
+ */
+ if (flags & SCF_DO_SUBSTR) {
+ scan_commit(pRExC_state, data, minlenp, is_inf);
+ flags &= ~SCF_DO_SUBSTR;
}
}
else if (OP(scan) == LOGICAL && scan->flags == 2) /* Embedded follows */