summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-06-09 21:25:46 -0600
committerKarl Williamson <khw@cpan.org>2016-06-17 12:45:20 -0600
commit8e84dec289732f088323c1bdc1e82f10841b362a (patch)
treecf8be93007ee95d578e0e4c1d0dd9bc857ea7557 /regcomp.c
parenta1399808f7d0c25a44b5677fd6cafda57e658955 (diff)
downloadperl-8e84dec289732f088323c1bdc1e82f10841b362a.tar.gz
Add missing deprecation message for unescaped '{' in regexes
The use of literal '{' without being escaped has been deprecated since 5.16, and warned on since 5.20. In 5.24, this has been made illegal, with a bunch of CPAN modules broken by it, in spite of the long deprecation period. See https://rt.perl.org/Ticket/Display.html?id=128139 Unfortunately, I overlooked a code path, and not all instances that should have warned did so in fact. This was spotted by Tom Wyant in https://rt.perl.org/Ticket/Display.html?id=128213 This commit adds that warning, and rewords the fatal one slightly, and clarifies the whole thing in perldiag.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/regcomp.c b/regcomp.c
index 86173db3e0..2e7805768b 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -13259,7 +13259,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
* something like "\b" */
if (len || (p > RExC_start && isALPHA_A(*(p -1)))) {
RExC_parse = p + 1;
- vFAIL("Unescaped left brace in regex is illegal");
+ vFAIL("Unescaped left brace in regex is illegal here");
}
/*FALLTHROUGH*/
default: /* A literal character */
@@ -13664,8 +13664,6 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
RExC_parse = p - 1;
Set_Node_Cur_Length(ret, parse_start);
RExC_parse = p;
- skip_to_be_ignored_text(pRExC_state, &RExC_parse,
- FALSE /* Don't force to /x */ );
{
/* len is STRLEN which is unsigned, need to copy to signed */
IV iv = len;
@@ -13677,6 +13675,13 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
break;
} /* End of giant switch on input character */
+ /* Position parse to next real character */
+ skip_to_be_ignored_text(pRExC_state, &RExC_parse,
+ FALSE /* Don't force to /x */ );
+ if (PASS2 && *RExC_parse == '{' && OP(ret) != SBOL && ! regcurly(RExC_parse)) {
+ ckWARNregdep(RExC_parse + 1, "Unescaped left brace in regex is deprecated here, passed through");
+ }
+
return(ret);
}