Re: perl: unsafe empty pattern behavior - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: perl: unsafe empty pattern behavior
Date
Msg-id 2385813054ce4e4b3e5998600da2ce95b9509dc7.camel@j-davis.com
Whole thread Raw
In response to Re: perl: unsafe empty pattern behavior  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: perl: unsafe empty pattern behavior
List pgsql-hackers
On Tue, 2024-03-12 at 18:53 +0100, Alvaro Herrera wrote:
> I suggest that pg_dump/t/002_pg_dump.pl could use a verification that
> the ->{regexp} thing is not empty.

I'm not sure how exactly to test for an empty pattern. The problem is,
we don't really want to test for an empty pattern, because /(?^:)/ is
fine. The problem is //, which gets turned into an actual pattern
(perhaps empty or perhaps not), and by the time it's in the %tests
hash, I think it's too late to distinguish.

Again, I'm not a perl expert, so suggestions welcome.

>   I also tried grepping (for things
> like qr{}, qr[], qr||, qr!!) and didn't find anything beyond what you
> have ... but I only looked for the "qr" literal, not other ways to
> get
> regexes.

I think that's fine. qr// seems the most dangerous, because it seems to
behave differently in different versions of perl.

Grepping for regexes in perl code is an "interesting" exercise.

Regards,
    Jeff Davis




pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: [EXTERNAL] Re: Add non-blocking version of PQcancel
Next
From: Tom Lane
Date:
Subject: Re: perl: unsafe empty pattern behavior