summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldelta.pod11
-rw-r--r--pod/perldiag.pod13
-rw-r--r--regcomp.c9
-rw-r--r--t/re/pat_advanced.t5
-rw-r--r--t/re/reg_mesg.t10
5 files changed, 27 insertions, 21 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 7ede889fb0..50d120a457 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 35cbb19af0..084db56d71 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 48d817b4f9..36626e3e3b 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 6e0b0dae76..74aed91124 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 db837d54d3..ff200834a3 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';") {