develooper Front page | perl.perl5.porters | Postings from April 2017

Re: [perl #130497] Revert "Unescaped left brace in regex" fatality

Thread Previous | Thread Next
From:
Karl Williamson
Date:
April 6, 2017 22:53
Subject:
Re: [perl #130497] Revert "Unescaped left brace in regex" fatality
Message ID:
171ba3e7-7502-7d26-33fe-44320702c833@khwilliamson.com
On 04/06/2017 03:51 PM, Karl Williamson wrote:
> On 04/06/2017 02:36 PM, Karl Williamson via RT wrote:
>> Reopened
>>
>
> Think about the following a little before doing a knee-jerk "No".
>
> What if we put in a kludge so that it remained fatal except when
> compiling the exact single pattern that autoconf uses?  It is
>
>     /\${[^\}]*}/
>
> Thus, when we are about to die, we check if the pattern attempting to be
> compiled is this exact one, and if so, merely warn.
>
> It is the one way I can think of that keeps us from being held hostage
> to this lackadaisical alien project for who knows how many more Decembers.
>
> What are the downsides?
>
> 1.   It is inelegant
> 2.   It is inelegant
> 3.   It is inelegant
>  ...
> n-1. It is inelegant
> n.   Any other code that has this exact pattern would compile instead of
> not.  But so what?  This particular pattern would not be affected by any
> of the proposed changes that making this illegal would allow.  They are,
> so far,
>
> a. to be able to say \w{something}
> b. to be able to have white space and a missing lower bound in {...}
> quantifiers.
>


I now offer a somewhat less kludgy idea.  Change the code so that at the 
point of raising the fatal message, it first looks at the current 
context.  If the left brace does not conflict with ideas we have as to 
how we could use it not-literally, then don't die but instead raise the 
warning.

This is more general than just the autoconf pattern, and so there are 
many more possible patterns that we would not die on, and this would not 
restrict our ability to make the currently foreseeable changes to left 
brace handling.  So if there are other things besides autoconf we 
haven't yet found, this would lessen the possibility that they would 
cause a problem.

Besides tests and pod, the only changes needed would be to insert these 
tests just before we currently die.

Thread Previous | 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