develooper Front page | perl.perl5.porters | Postings from January 2016

[perl #8904] Missing warning for /[[:digit]]/

Thread Next
From:
James E Keenan via RT
Date:
January 23, 2016 03:42
Subject:
[perl #8904] Missing warning for /[[:digit]]/
Message ID:
rt-4.0.18-28937-1453520566-255.8904-15-0@perl.org
On Wed Sep 16 11:40:33 2015, public@khwilliamson.com wrote:
> On 09/16/2015 10:40 AM, Zefram wrote:
> > Eric Brine wrote:
> >> Better yet, the following demonstrates how concatenation two valid
> >> regex
> >> patterns producing an invalid one:
> >
> > It's even worse than that:
> >
> > $ perl -e '$a=qr/[abc[=]/; $b=qr/=]/; qr/$a$b/'
> > Unmatched [ in regex; marked by <-- HERE in m/(?^:[ <-- HERE
> > abc[=])(?^:=])/ at -e line 1.
> >
> > Fails without any explicit string concatenation.  Interpolation of a
> > regexp object into qr// normally interpolates the meaning of the
> > regexp
> > as a syntactically atomic element, and the stringification of a
> > regexp
> > object has parens matching that behaviour.  But here it turns out
> > it's
> > doing a dirty old string concatenation underneath.
> >
> > -zefram
> >
> 
> 
> Hmm.  Actually it's not doing a string concatenation, if you look at
> the
> message it shows that $b was stringified into (?^:
> The problem is that the parsing code is using a defective pattern to
> find its expected closing delimiter, a pattern that unfortunately is
> used in various places in perl's parsing.  You can't generally just
> use
> strchr or memchr, or in this case a while loop to look ahead without
> bothering to see what's in the middle.  strchr suffers from the
> additional problem that NULs are legitimate in Perl strings.

khw:  Do you have any thoughts as to how we might resolve this ticket?

Thank you very much.

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

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

Thread Next


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