[Pdx-pm] testing simulated CGI input

publiustemp-pdxpm at yahoo.com publiustemp-pdxpm at yahoo.com
Sun Sep 12 13:17:11 CDT 2004

>      system 'perl',
>          '-Ilib',     # to find the modules in the dev directory
>          't/91cgi_methods.cgi',     # the name of the test
>          'number=3172',     # parameters ...
>          'name=Lava lamp',
>          'price=27.99',
>          'crackme=;rm / -rf',
>      ;
> and i wonder, more generally, if anyone knows of a better way to do 
> this?

Hi Randall,

Since you are not testing CGI.pm and are just testing your particular form handling module, why
not just call the script directly and have the query string embedded in the script?  It seems like
it would be much easier that way.

  $ENV{QUERY_STRING} = 'number=3172;name=Lava%20lamp;price=27.99;crackme=%25rm%20%2F%20-rf'; 
  my $cgi = CGI->new;
  print $cgi->param('number');

(Or build that string with the URI module or something similar)

Not only is this easier, but then your test script can contain everything it needs to run instead
of being dependent on a system call from something else.  Or did I misunderstand something here?


Silence is Evil            http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid                       http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/

More information about the Pdx-pm-list mailing list