CGI::Untaint::boolean - untaint boolean values from CGI programs
use CGI::Untaint; my $handler = CGI::Untaint->new( $q->Vars() ); my $boolean = $handler->extract( -as_boolean => 'some_feature' );
This input handler verifies that it is dealing with a reasonable boolean value, probably from a checkbox with no value specified. In this case, "reasonable" means that the value is
on, if the checkbox is checked, or empty, if the client did not send a value.
value() method will return either true or false. It will not return the string "on" or the empty string. It's boolean for a reason! (Don't count on it returning
0 for false either; false is just false.)
Returns true if the value for this checkbox is valid, setting the value to true if the value is
on, false otherwise.
chromatic at wgz dot org
Thanks to Tony Bowden for helpful suggestions, Simon Wilcox for reporting a false value bug, with a test patch, and Dave Wilcox for helping to disambiguate the documentation.
No known bugs. Please report any to http://rt.cpan.org/.
Copyright (c) 2004 - 2005, chromatic. All rights reserved. You may use, modify, and distribute this module under the same terms as Perl 5.8.x itself, in the hope that it is useful but certainly under no guarantee.