diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-02-28 13:17:14 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-03-02 09:13:23 +0000 |
commit | 81cba34dfec599a5c705d6fae7bffa4076614bba (patch) | |
tree | 93b19202faf250d32f9e65b4987dc677e535ccf7 /t | |
parent | e75436bfac7b4a53ab5cdbe3480311e33f29ceed (diff) | |
download | perl-81cba34dfec599a5c705d6fae7bffa4076614bba.tar.gz |
In taint.t, replace C<not any_tainted(..)> with calls to isnt_tainted()
Change tainted() to perform the actual test for tainting, eliminate all other
uses of any_tainted() and remove it.
Diffstat (limited to 't')
-rw-r--r-- | t/op/taint.t | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/t/op/taint.t b/t/op/taint.t index 241817fe8e..13cbacaadc 100644 --- a/t/op/taint.t +++ b/t/op/taint.t @@ -17,7 +17,7 @@ use Config; use File::Spec::Functions; BEGIN { require './test.pl'; } -plan tests => 712; +plan tests => 733; $| = 1; @@ -97,23 +97,20 @@ sub taint_these (@) { } # How to identify taint when you see it -sub any_tainted (@) { - not eval { join("",@_), kill 0; 1 }; -} sub tainted ($) { - any_tainted @_; + not eval { join("",@_), kill 0; 1 }; } sub is_tainted { my $thing = shift; local $::Level = $::Level + 1; - ok(any_tainted($thing), @_); + ok(tainted($thing), @_); } sub isnt_tainted { my $thing = shift; local $::Level = $::Level + 1; - ok(!any_tainted($thing), @_); + ok(!tainted($thing), @_); } # We need an external program to call. @@ -228,11 +225,10 @@ my $TEST = catfile(curdir(), 'TEST'); is_tainted($foo); my @list = 1..10; - ok(not any_tainted @list); + isnt_tainted($_) foreach @list; taint_these @list[1,3,5,7,9]; - ok(any_tainted @list); is_tainted($_) foreach @list[1,3,5,7,9]; - ok(not any_tainted @list[0,2,4,6,8]); + isnt_tainted($_) foreach @list[0,2,4,6,8]; ($foo) = $foo =~ /(.+)/; isnt_tainted($foo); @@ -1007,13 +1003,18 @@ SKIP: { is_tainted($foo); $foo =~ /def/; - ok(not any_tainted $`, $&, $'); + isnt_tainted($`); + isnt_tainted($&); + isnt_tainted($'); $foo =~ /(...)(...)(...)/; - ok(not any_tainted $1, $2, $3, $+); + isnt_tainted($1); + isnt_tainted($2); + isnt_tainted($3); + isnt_tainted($+); my @bar = $foo =~ /(...)(...)(...)/; - ok(not any_tainted @bar); + isnt_tainted($_) foreach @bar; is_tainted($foo); # $foo should still be tainted! is($foo, "abcdefghi"); @@ -1761,13 +1762,15 @@ TERNARY_CONDITIONALS: { if ( $foo eq '' ) { } elsif ( $foo =~ /([$valid_chars]+)/o ) { - isnt_tainted($1); + isnt_tainted($1); + isnt($1, undef); } if ( $foo eq '' ) { } elsif ( my @bar = $foo =~ /([$valid_chars]+)/o ) { - ok(not any_tainted @bar); + isnt_tainted($bar[0]); + is(scalar @bar, 1); } } |