CGI::Untaint::set - untaint sets of values


CGI-Untaint-set documentation Contained in the CGI-Untaint-set distribution.

Index


Code Index:

NAME

Top

CGI::Untaint::set - untaint sets of values

SYNOPSIS

Top

    use CGI::Untaint;
    my $handler = CGI::Untaint->new($q->Vars);

    $value = $handler->extract(-as_set => 'films' );    




DESCRIPTION

Top

Untaints an arrayref (as might be submitted by an HTML multiple select form field, or multiple selections from a checkbox group) as a comma separated string suitable for use as a value for a MySQL (maybe others?) SET column.

Values are validated against the CGI::Untaint::printable regex. To validate against a specific set of allowed values, subclass this package and provide a custom _untaint_re method.

AUTHOR

Top

David Baird, <cpan@riverside-cms.co.uk>

BUGS

Top

Please report any bugs or feature requests to bug-cgi-untaint-set@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Untaint-set. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


CGI-Untaint-set documentation Contained in the CGI-Untaint-set distribution.
package CGI::Untaint::set;

use warnings;
use strict;

use base 'CGI::Untaint::printable';

our $VERSION = 0.01;

sub _untaint
{
    my ( $self ) = @_;
    
    my $value = $self->value;
    
    return $self->SUPER::_untaint unless ref $value;
    
    my $re = $self->_untaint_re;

    $self->value( join ',', map { $_ =~ $re or die; $1 } @$value );
    
    return 1;
}



1; # End of CGI::Untaint::set