Substitutions based on Posix ERE's in perl

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
For a project I have to implement lookup using NAPTR records from
DNS. Basicaly the consist of an substitution using POSIX ERE
syntax. (See RFC 3403).

Parsing the regexp to perl with minor corrections would probably solve
my problem in maost of the well behaved cases. But what about the not
so well behaved cases?

Is there an easy way to sanitize a regular expression such that it
is safe to run? Or should I write a full translation from ERE to perl?

Searhing CPAN doesn't ive me anything usefull.

Any other ideas?


Re: Substitutions based on Posix ERE's in perl

Quoted text here. Click to load it

Easy way?  I doubt it.  Perl regexp has too many special constructs
multiple uses of characters to be very easy.  I would treat it like a
taint check on a web form: only allow what you know to be safe and
anything else.  Then do a non-interpolating substitution to prevent
leaking any information.  So maybe convert /LHS/RHS/ to s'LHS'RHS'
where you have checked for legal characters and sequences in LHS and
and translated any differing POSIX-ish into Perl-ish.

Somebody must have made a comprehensive set of test cases for this
as part of reviewing it.  Find that.

Re: Substitutions based on Posix ERE's in perl

Quoted text here. Click to load it

I take it Regex::POSIX isn't good enough? It doesn't appear to support
returning the match positions, which would be required to do a

If you have 5.10 re::engine::POSIX would be the obvious thing to use.


Site Timeline