Commit | Line | Data |
317ea90d |
1 | #!./perl -t |
6537fe72 |
2 | |
3 | BEGIN { |
4 | chdir 't'; |
5 | @INC = '../lib'; |
6 | require './test.pl'; |
7 | } |
8 | |
317ea90d |
9 | plan tests => 11; |
6537fe72 |
10 | |
11 | my $Perl = which_perl(); |
12 | |
13 | my $warning; |
14 | local $SIG{__WARN__} = sub { $warning = join "\n", @_; }; |
15 | my $Tmsg = 'while running with -t switch'; |
16 | |
17 | ok( ${^TAINT}, '${^TAINT} defined' ); |
18 | |
19 | my $out = `$Perl -le "print q{Hello}"`; |
20 | is( $out, "Hello\n", '`` worked' ); |
21 | like( $warning, qr/^Insecure .* $Tmsg/, ' taint warn' ); |
22 | |
23 | { |
24 | no warnings 'taint'; |
25 | $warning = ''; |
26 | my $out = `$Perl -le "print q{Hello}"`; |
27 | is( $out, "Hello\n", '`` worked' ); |
28 | is( $warning, '', ' no warnings "taint"' ); |
29 | } |
30 | |
31 | # Get ourselves a tainted variable. |
32 | $file = $0; |
33 | $file =~ s/.*/some.tmp/; |
34 | ok( open(FILE, ">$file"), 'open >' ) or DIE $!; |
35 | print FILE "Stuff\n"; |
36 | close FILE; |
37 | like( $warning, qr/^Insecure dependency in open $Tmsg/, 'open > taint warn' ); |
38 | ok( -e $file, ' file written' ); |
39 | |
40 | unlink($file); |
41 | like( $warning, qr/^Insecure dependency in unlink $Tmsg/, |
42 | 'unlink() taint warn' ); |
43 | ok( !-e $file, 'unlink worked' ); |
317ea90d |
44 | |
45 | ok( !$^W, "-t doesn't enable regular warnings" ); |