In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/1656665e748b80ad0727244ca0eae788f521f64f?hp=60108b47d6130990788b7498d939598cebe8a0b8>
- Log ----------------------------------------------------------------- commit 1656665e748b80ad0727244ca0eae788f521f64f Author: Karl Williamson <[email protected]> Date: Fri Apr 8 12:13:06 2016 -0600 Require literal '{' in patterns to be escaped This has been deprecated since v5.16, with a deprecation message displayed starting in v5.22. M pod/perldelta.pod M pod/perldiag.pod M regcomp.c M t/re/pat_advanced.t M t/re/reg_mesg.t commit a27615d67331a9b30d8e49e84614dffb27b77acc Author: Karl Williamson <[email protected]> Date: Fri Apr 8 12:07:05 2016 -0600 ext/B/t/OptreeCheck.pm: Escape literal pattern '{' The deprecated warnings were getting suppressed, but literal '{' in patterns needs to be escaped. M ext/B/t/OptreeCheck.pm ----------------------------------------------------------------------- Summary of changes: ext/B/t/OptreeCheck.pm | 6 +++--- pod/perldelta.pod | 11 +++++++++++ pod/perldiag.pod | 13 ++++++++----- regcomp.c | 9 ++++----- t/re/pat_advanced.t | 5 ----- t/re/reg_mesg.t | 10 ++++------ 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/ext/B/t/OptreeCheck.pm b/ext/B/t/OptreeCheck.pm index a099a97..3ae1930 100644 --- a/ext/B/t/OptreeCheck.pm +++ b/ext/B/t/OptreeCheck.pm @@ -5,7 +5,7 @@ use warnings; use vars qw($TODO $Level $using_open); require "test.pl"; -our $VERSION = '0.13'; +our $VERSION = '0.14'; # now export checkOptree, and those test.pl functions used by tests our @EXPORT = qw( checkOptree plan skip skip_all pass is like unlike @@ -703,12 +703,12 @@ sub mkCheckRex { .* # all sorts of things follow it v # The opening v ) - (?:(:>,<,%,\\{) # hints when open.pm is in force + (?:(:>,<,%,\\\{) # hints when open.pm is in force |(:>,<,%)) # (two variations) (\ ->(?:-|[0-9a-z]+))? $ ] - [$1 . ($2 && ':{') . $4]xegm; # change to the hints without open.pm + [$1 . ($2 && ':\{') . $4]xegm; # change to the hints without open.pm } diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 7ede889..50d120a 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -32,6 +32,17 @@ L</Selected Bug Fixes> section. [ List each security issue as a =head2 entry ] +=head2 Unescaped literal C<"{"> characters in regular expression +patterns are no longer permissible + +You have to now say something like C<"\{"> or C<"[{]"> to specify to +match a LEFT CURLY BRACKET. This will allow future extensions to the +language. This restriction is not enforced, nor are there current plans +to enforce it, if the C<"{"> is the first character in the pattern. + +These have been deprecated since v5.16, with a deprecation message +displayed starting in v5.22. + =head2 Literal control character variable names are no longer permissible A variable name may no longer contain a literal control character under diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 35cbb19..084db56 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -6127,18 +6127,21 @@ C<undef *foo>. (A) You've accidentally run your script through B<csh> instead of Perl. Check the #! line, or manually feed your script into Perl yourself. -=item Unescaped left brace in regex is deprecated, passed through in regex; +=item Unescaped left brace in regex is illegal in regex; marked by S<<-- HERE> in m/%s/ -(D deprecated, regexp) You used a literal C<"{"> character in a regular -expression pattern. You should change to use C<"\{"> instead, because a -future version of Perl (tentatively v5.26) will consider this to be a -syntax error. If the pattern delimiters are also braces, any matching +(F) You used a literal C<"{"> character in a regular +expression pattern. You should change to use C<"\{"> or C<[{]> instead. +If the pattern delimiters are also braces, any matching right brace (C<"}">) should also be escaped to avoid confusing the parser, for example, qr{abc\{def\}ghi} +This restriction is not enforced if the C<"{"> is the first character in +the pattern; nor is a warning generated for this case, as there are no +current plans to forbid it. + =item unexec of %s into %s failed! (F) The unexec() routine failed for some reason. See your local FSF diff --git a/regcomp.c b/regcomp.c index 48d817b..36626e3 100644 --- a/regcomp.c +++ b/regcomp.c @@ -13190,14 +13190,13 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth) } /* End of switch on '\' */ break; case '{': - /* Currently we don't warn when the lbrace is at the start + /* Currently we don't care if the lbrace is at the start * of a construct. This catches it in the middle of a * literal string, or when it's the first thing after * something like "\b" */ - if (! SIZE_ONLY - && (len || (p > RExC_start && isALPHA_A(*(p -1))))) - { - ckWARNregdep(p + 1, "Unescaped left brace in regex is deprecated, passed through"); + if (len || (p > RExC_start && isALPHA_A(*(p -1)))) { + RExC_parse = p + 1; + vFAIL("Unescaped left brace in regex is illegal"); } /*FALLTHROUGH*/ default: /* A literal character */ diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t index 6e0b0da..74aed91 100644 --- a/t/re/pat_advanced.t +++ b/t/re/pat_advanced.t @@ -1159,11 +1159,6 @@ sub run_tests { } { - # \, breaks {3,4} - no warnings qw{deprecated regexp}; - ok "xaaay" !~ /xa{3\,4}y/, '\, in a pattern'; - ok "xa{3,4}y" =~ /xa{3\,4}y/, '\, in a pattern'; - # \c\ followed by _ ok "x\c_y" !~ /x\c\_y/, '\_ in a pattern'; ok "x\c\_y" =~ /x\c\_y/, '\_ in a pattern'; diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index db837d5..ff20083 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -268,6 +268,10 @@ my @death = '/(?[\ |!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ |!{#}])/', # [perl #126180] '/(?[()-!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[()-!{#}])/', # [perl #126204] '/(?[!()])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[!(){#}])/', # [perl #126404] + '/\w{/' => 'Unescaped left brace in regex is illegal {#} m/\w{{#}/', + '/\q{/' => 'Unescaped left brace in regex is illegal {#} m/\q{{#}/', + '/:{4,a}/' => 'Unescaped left brace in regex is illegal {#} m/:{{#}4,a}/', + '/xa{3\,4}y/' => 'Unescaped left brace in regex is illegal {#} m/xa{{#}3\,4}y/', '/abc/xix' => 'Only one /x regex modifier is allowed', '/(?xmsixp:abc)/' => 'Only one /x regex modifier is allowed {#} m/(?xmsixp{#}:abc)/', '/(?xmsixp)abc/' => 'Only one /x regex modifier is allowed {#} m/(?xmsixp{#})abc/', @@ -617,12 +621,6 @@ my @experimental_regex_sets = ( ); my @deprecated = ( - '/\w{/' => 'Unescaped left brace in regex is deprecated, passed through {#} m/\w{{#}/', - '/\q{/' => [ - 'Unrecognized escape \q{ passed through {#} m/\q{{#}/', - 'Unescaped left brace in regex is deprecated, passed through {#} m/\q{{#}/' - ], - '/:{4,a}/' => 'Unescaped left brace in regex is deprecated, passed through {#} m/:{{#}4,a}/', ); for my $strict ("", "use re 'strict';") { -- Perl5 Master Repository
