Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Substitutions based on Posix ERE's in perl

Reply
Thread Tools

Substitutions based on Posix ERE's in perl

 
 
Peter Makholm
Guest
Posts: n/a
 
      04-05-2009
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?


//Makholm
 
Reply With Quote
 
 
 
 
smallpond
Guest
Posts: n/a
 
      04-06-2009
On Apr 5, 11:57 am, Peter Makholm <pe...@makholm.net> wrote:
> 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?
>
> //Makholm



Easy way? I doubt it. Perl regexp has too many special constructs
and
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
deny
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
RHS
and translated any differing POSIX-ish into Perl-ish.

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
separating substitutions from an embedded perl in a ksh script tazommers@yahoo.com Perl Misc 4 04-04-2008 07:23 PM
Multiple Substitutions in perl kd Perl Misc 3 10-16-2005 08:51 PM
Mass importing of a template based system.. Trouble with name substitutions rh0dium Python 6 08-05-2005 05:25 AM
using templates as substitutions for #ifdef Chris Goller C++ 4 03-09-2005 12:17 AM
Ant problem with property substitutions. RJGraham Java 6 06-28-2004 03:49 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57