in reply to Mulitple constraints for Data::FormValidator
Try to trick it with dependencies.
$q->param( userid_untaint => 'dummy junk' ); my $dfv_profile = { required => [qw (userid_untaint)], dependencies => { userid_untaint => [ qw( userid ) ], }, constraints => { userid => { name => 'userid_exists', constraint => sub { return !MyDBITools->user_exists($ca_obj); }, }, userid_untaint => { name => 'userid_untaint', constraint => sub { my $tmp = $q->param( 'userid' ); $tmp =~ s/^[-\@\w.]+$/; $q->param( userid => $tmp ); }, }, }, msgs => { format => '%s', constraints => { 'userid_exists' => "User ID already exists.", 'userid_untaint'=> "User ID contains bad stuff", }, }, };
The idea being to use a dummy constraint to do the untainting. This assumes that the module will perform the userid_untaint first because it's required, that will re-set the userid parameter with an untainted version, then dependencies will force the userid to be required also, then the module will run the userid validation which then performs the original function on the now untainted value.
I have no idea if this will actually work.
Why can't you untaint and check your database at the same time?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Mulitple constraints for Data::FormValidator
by Anneq (Vicar) on Apr 17, 2004 at 01:48 UTC | |
by matthewb (Curate) on Jul 29, 2004 at 11:55 UTC |