Skip to content

Commit 5efad79

Browse files
committed
Fix panic in Unicode wildcard matching
The reason this bug occurs is that wildcard matching changes the anchor assertions \A, \Z, and \z, without corresponding changes in regexec.c. We earlier noticed that all these were being marked SIMPLE, and a zero-width construct shouldn't really be. But it was considered too late in the development cycle to make that change. So the plan was to live with this bug in an experimental feature in 5.32. But I eventually realized that the change could be effected for just the wildcard versions, and this commit does that. If there is some issue with making these non-SIMPLE, it will affect only the wildcard feature, and those potential bugs are better than a known bug. I also seems unlikely that this will introduce any bug. What removing SIMPLE does is merely remove potential optimizations in the handling. The most general case should work.�; it's doing an improper optimization that gets one into trouble. This fixes #17677
1 parent a964bf3 commit 5efad79

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

regcomp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13565,8 +13565,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1356513565
/* SBOL is shared with /^/ so we set the flags so we can tell
1356613566
* /\A/ from /^/ in split. */
1356713567
FLAGS(REGNODE_p(ret)) = 1;
13568+
*flagp |= SIMPLE; /* Wrong, but too late to fix for 5.32 */
1356813569
}
13569-
*flagp |= SIMPLE;
1357013570
goto finish_meta_pat;
1357113571
case 'G':
1357213572
if (RExC_pm_flags & PMf_WILDCARD) {
@@ -13604,8 +13604,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1360413604
}
1360513605
else {
1360613606
ret = reg_node(pRExC_state, SEOL);
13607+
*flagp |= SIMPLE; /* Wrong, but too late to fix for 5.32 */
1360713608
}
13608-
*flagp |= SIMPLE;
1360913609
RExC_seen_zerolen++; /* Do not optimize RE away */
1361013610
goto finish_meta_pat;
1361113611
case 'z':
@@ -13615,8 +13615,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1361513615
}
1361613616
else {
1361713617
ret = reg_node(pRExC_state, EOS);
13618+
*flagp |= SIMPLE; /* Wrong, but too late to fix for 5.32 */
1361813619
}
13619-
*flagp |= SIMPLE;
1362013620
RExC_seen_zerolen++; /* Do not optimize RE away */
1362113621
goto finish_meta_pat;
1362213622
case 'C':

0 commit comments

Comments
 (0)