develooper Front page | perl.perl5.porters | Postings from August 2019

[perl #134141] Further elimination of unescaped left braces inregular expressions

From:
James E Keenan via RT
Date:
August 9, 2019 21:28
Subject:
[perl #134141] Further elimination of unescaped left braces inregular expressions
Message ID:
rt-4.0.24-5528-1565386085-57.134141-15-0@perl.org
On Sat, 25 May 2019 02:18:57 GMT, jkeenan@pobox.com wrote:
> pod/perldeprecation.pod contains the following entry for perl-5.32:
> 
> #####
> Unescaped left braces in regular expressions
> 
> The simple rule to remember, if you want to match a literal
> "{" character (U+007B "LEFT CURLY BRACKET") in a regular
> expression pattern, is to escape each literal instance of
> it in some way. Generally easiest is to precede it with a
> backslash, like "\{" or enclose it in square brackets
> ("[{]"). If the pattern delimiters are also braces, any
> matching right brace ("}") should also be escaped to avoid
> confusing the parser, for example,
> 
> qr{abc\{def\}ghi}
> 
> Forcing literal "{" characters to be escaped will enable
> the Perl language to be extended in various ways in future
> releases. To avoid needlessly breaking existing code, the
> restriction is is not enforced in contexts where there are
> unlikely to ever be extensions that could conflict with the
> use there of "{" as a literal. A non-deprecation warning
> that the left brace is being taken literally is raised in
> contexts where there could be confusion about it.
> 
> Literal uses of "{" were deprecated in Perl 5.20, and some
> uses of it started to give deprecation warnings since.
> These cases were made fatal in Perl 5.26. Due to an
> oversight, not all cases of a use of a literal "{" got a
> deprecation warning. Some cases started warning in Perl
> 5.26, and were made fatal in Perl 5.30. Other cases started
> in Perl 5.28, and will be made fatal in 5.32.
> #####
> 
> This entry was recorded in the following commit:
> 
> #####
> commit 0367231ce260cd08bcb13082d510e5778668bcc1
> Author: Karl Williamson <khw@cpan.org>
> Date: Thu Jan 4 12:53:29 2018 -0700
> 
> Raise deprecation for qr/(?foo})/
> 
> An unescaped left brace that is meant to be taken literally
> is officially deprecated, though there are no plans to
> remove it in contexts where we don't expect to use it to
> mean something else, and no warning is raised in those
> contexts.
> 
> reg_mesg.t tests the known set of these contexts, currently
> (after this commit):
> 
> /^{/ /foo|{/ /foo|^{/ /foo(:?{bar)/ /\s*{/ /a{3,4}{/
> 
> This commit deprecates this context: /foo({bar})/
> 
> This probably should have been illegal all along when 'bar'
> is a valid quantifier, as we do with the other quantifiers
> that follow a left paren whose illegality we haven't
> already taken advantage of to mean something else:
> 
> qr/(+0)/ Quantifier follows nothing in regex
> 
> This deprecation will allow ({...}) to be usable for a
> possible future regex extension
> #####
> 
> Make it so.

Karl, do you expect to be taking this ticket on soon?  It's on our 5.32 blockers list.

Thanks.

-- 
James E Keenan (jkeenan@cpan.org)

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=134141



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About