in reply to Validating Regular Expression
Eval is great for getting perl to tell you if something is technically legal or not. But I have a concern.
The task is a little more complex than that. You will have to prevent the (?{code}) construct from finding its way into your user's input, lest they manage to inject some unsavory tidbit into your system. That's just the start. Will your users have the ability to input RE's that are expressed in /x terms? (In other words, where whitespace is not relevant.) They could always use (?x:.....), or any of the other legal options to sort of control the RE's destiny, possibly in a way that you weren't intending. I think that the greater task is not in validating the RE's viability, so much as evaluating its security risk.
As for validating its viability, eval isn't such a bad tool. You would be able to let perl tell you if there's a problem. But perl cannot know if there's a security breech.
I don't know all the possible risks that you should test for. But at minimum disallowing code blocks would be a start.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Validating Regular Expression
by ikegami (Patriarch) on Feb 15, 2011 at 17:46 UTC | |
|
Re^2: Validating Regular Expression
by kennethk (Abbot) on Feb 15, 2011 at 16:42 UTC | |
by Anonymous Monk on Feb 15, 2011 at 17:54 UTC | |
|
Re^2: Validating Regular Expression
by JavaFan (Canon) on Feb 15, 2011 at 16:53 UTC | |
|
Re^2: Validating Regular Expression
by Anonymous Monk on Feb 15, 2011 at 16:37 UTC |