summaryrefslogtreecommitdiff
path: root/t/run
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2001-12-13 14:27:08 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-14 14:43:40 +0000
commit6537fe72dd6d63cc0c7164fec44beb82d2568599 (patch)
tree32c01336d785c38d130126526438bf4951f89791 /t/run
parenta58d912c5262ef3032191d4aea207683577527bb (diff)
downloadperl-6537fe72dd6d63cc0c7164fec44beb82d2568599.tar.gz
-t taint warnings
Message-ID: <20011214002707.GA10532@blackrider> (reword the perlrun -t description a bit, and move the Itaint_warn to the bottom of the intrpvar.h for binary compatibility) p4raw-id: //depot/perl@13684
Diffstat (limited to 't/run')
-rw-r--r--t/run/switcht.t43
1 files changed, 43 insertions, 0 deletions
diff --git a/t/run/switcht.t b/t/run/switcht.t
new file mode 100644
index 0000000000..bb52252291
--- /dev/null
+++ b/t/run/switcht.t
@@ -0,0 +1,43 @@
+#!./perl -tw
+
+BEGIN {
+ chdir 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+plan tests => 10;
+
+my $Perl = which_perl();
+
+my $warning;
+local $SIG{__WARN__} = sub { $warning = join "\n", @_; };
+my $Tmsg = 'while running with -t switch';
+
+ok( ${^TAINT}, '${^TAINT} defined' );
+
+my $out = `$Perl -le "print q{Hello}"`;
+is( $out, "Hello\n", '`` worked' );
+like( $warning, qr/^Insecure .* $Tmsg/, ' taint warn' );
+
+{
+ no warnings 'taint';
+ $warning = '';
+ my $out = `$Perl -le "print q{Hello}"`;
+ is( $out, "Hello\n", '`` worked' );
+ is( $warning, '', ' no warnings "taint"' );
+}
+
+# Get ourselves a tainted variable.
+$file = $0;
+$file =~ s/.*/some.tmp/;
+ok( open(FILE, ">$file"), 'open >' ) or DIE $!;
+print FILE "Stuff\n";
+close FILE;
+like( $warning, qr/^Insecure dependency in open $Tmsg/, 'open > taint warn' );
+ok( -e $file, ' file written' );
+
+unlink($file);
+like( $warning, qr/^Insecure dependency in unlink $Tmsg/,
+ 'unlink() taint warn' );
+ok( !-e $file, 'unlink worked' );