Taint
view release on metacpan or search on metacpan
t/0-basic.t view on Meta::CPAN
sub test ($$;$) {
my($num, $bool, $diag) = @_;
if ($bool) {
print "ok $num\n";
return;
}
print "not ok $num\n";
return unless defined $diag;
$diag =~ s/\Z\n?/\n/; # unchomp
print map "# $num : $_", split m/^/m, $diag;
}
test 2, $Taint::VERSION > 0.08;
my $foo = "bar";
test 3, not is_tainted $foo;
test 4, not any_tainted $foo;
test 5, not all_tainted $foo;
my @foo = qw(this is a test);
t/no-taint.t view on Meta::CPAN
sub test ($$;$) {
my($num, $bool, $diag) = @_;
if ($bool) {
print "ok $num\n";
return;
}
print "not ok $num\n";
return unless defined $diag;
$diag =~ s/\Z\n?/\n/; # unchomp
print map "# $num : $_", split m/^/m, $diag;
}
test 1, not taint_checking;
my $foo = tainted_null;
test 2, not is_tainted($foo);
test 3, not any_tainted(tainted_null, tainted_zero);
test 4, not is_tainted taintedness tainted_null;
exit;
sub test ($$;$) {
my($num, $bool, $diag) = @_;
if ($bool) {
print "ok $num\n";
return;
}
print "not ok $num\n";
return unless defined $diag;
$diag =~ s/\Z\n?/\n/; # unchomp
print map "# $num : $_", split m/^/m, $diag;
}
{
package MagicScalar;
# A MagicScalar may be assigned any number of values.
# When evaluated, it returns one of them at random, with
# the most likely ones being the least recently returned.
#
# Because its values can't be set in the usual
t/u-untaint.t view on Meta::CPAN
sub test ($$;$) {
my($num, $bool, $diag) = @_;
if ($bool) {
print "ok $num\n";
return;
}
print "not ok $num\n";
return unless defined $diag;
$diag =~ s/\Z\n?/\n/; # unchomp
print map "# $num : $_", split m/^/m, $diag;
}
my @foo = 1..10;
test 1, not any_tainted(@foo);
taint(@foo);
test 2, all_tainted(@foo);
unconditional_untaint($foo[4]);
test 3, not all_tainted(@foo);
test 4, any_tainted(@foo);
test 5, tainted( $foo[3]);
( run in 0.547 second using v1.01-cache-2.11-cpan-71847e10f99 )