develooper Front page | perl.perl5.porters | Postings from September 2013

Re: Regex \8 and \9 after literals no longer work

Thread Previous | Thread Next
From:
Tim Jenness
Date:
September 9, 2013 19:30
Subject:
Re: Regex \8 and \9 after literals no longer work
Message ID:
CA+G92Rfm2vqs-GKANcgH+3TUy14F1E85DkDrHCp2iNUUxijx1w@mail.gmail.com
Would it help discussion if I filed a perl bug against 5.18.x and mentioned
the fix is already available?

-- 
Tim Jenness

On Fri, Sep 6, 2013 at 11:03 PM, Tim Jenness <tim.jenness@gmail.com> wrote:

>
>
> On Tue, Jun 25, 2013 at 3:38 PM, demerphq <demerphq@gmail.com> wrote:
>
>>
>> >>
>> >> (The change breaks the latex2html package, btw.)
>> >
>> > Thanks for the report. I agree this is a bug. I am looking into a fix.
>>
>> I ended up pushing the following:
>>
>> f1e1b256c5c1773d90e828cca6323c53fa23391b
>>
>> which makes multidigit backslash escapes illegal when they start with
>> 8 or 9 and are larger than the number of capture buffers in the
>> string.
>>
>> IOW, /\87/ is a fatal error and not /\x{00}87/ nor /87/ with a
>> warning. My rationale for this is we have two precedents to consider:
>>
>> a) a case like /\9/ where we would die with an error about a
>> backreference to a non-existent buffer.
>> b) a case like "\9" where we would warn, and then treat the escape as "9".
>>
>> IMO the precedent for the regex wins over the precedent of the double
>> quoted string.
>>
>> The rules for handling backreferences are pretty arcane. \118 could
>> mean the 118th capture buffer, if it exists, or it could mean
>> "\x{09}8". In other words not only do we change the base we interpret
>> it in, we also change the number of digits we consider part of the
>> escape!
>>
>> This patch does not change this behavior, and affects only escapes
>> starting with an 8 or 9 as they have no reasonable interpretation as
>> octal,  but do have reasonable interpretations as back references.
>>
>> I personally think maybe we should warn on something like \118, but i
>> leave that debate for another day.
>>
>>
> I've just come across this bug and it's a bit of disaster for people that
> use latex2html. Is there a reason why the fix didn't make it in to v5.18.1?
> This works fine in 5.16.x and is clear breakage in v5.18.x. I can't upgrade
> my perl until latex2html works again.
>
> See also https://bugzilla.redhat.com/show_bug.cgi?id=978233 and it seems
> that RedHat are considering applying the patch themselves.
>
> --
> Tim Jenness
>
>

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