Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- matching all perldoc names but no more
November 6, 2004, 2:40 pm
rate this thread
should purify my actual problem:
I am allowing a user to enter a perldoc name and I will run 'perldoc $name'
What regex will match all perldoc names but not allow for a command to be
slipped into the name.
for example, here is my latest:
if you allowed just anything:
a user could enter 'perlref | rm -r ./*' or something like that.
seemed perfect but left out perlfaq1-9
left out CGI and other ones with caps.
Is there a rule for all current and future perldoc names? I mean, they
can't possible have a | or a > in their name or even a space in the middle,
Re: matching all perldoc names but no more
> I was getting carried away answering myself in another thread so I
> thought I should purify my actual problem:
> I am allowing a user to enter a perldoc name and I will run 'perldoc
> $name' for them.
I thinking you are going down the wrong road. You know exactly the list of
phrases you want to allow. Why don't you just restrict the options to that.
Even if you do not have Perl on your computer, it is not hard to write
script to parse the output of perldoc perltoc. That will give you the list
of allowable phrases. Now, you can make sure the phrase sent to your CGI
matches only one of those in the set of allowable perldoc arguments.