Substitutions based on Posix ERE's in perl

Discussion in 'Perl Misc' started by Peter Makholm, Apr 5, 2009.

  1. 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
     
    Peter Makholm, Apr 5, 2009
    #1
    1. Advertising

  2. Peter Makholm

    smallpond Guest

    On Apr 5, 11:57 am, Peter Makholm <> 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.
     
    smallpond, Apr 6, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rh0dium
    Replies:
    6
    Views:
    278
    Dennis Lee Bieber
    Aug 5, 2005
  2. Wesley Chen
    Replies:
    0
    Views:
    248
    Wesley Chen
    Apr 7, 2009
  3. Wesley Chen
    Replies:
    9
    Views:
    263
    Sean O'Halpin
    Apr 14, 2009
  4. Ivan Shmakov

    "walk over," and XPath-based substitutions?

    Ivan Shmakov, Apr 6, 2013, in forum: Perl Misc
    Replies:
    3
    Views:
    251
    Ivan Shmakov
    Apr 7, 2013
  5. Ivan Shmakov
    Replies:
    2
    Views:
    535
    Joe Kesselman
    Apr 7, 2013
Loading...

Share This Page