1#!./perl -Tw 2# Testing Cwd under taint mode. 3 4use strict; 5 6use Cwd; 7chdir 't' unless $ENV{PERL_CORE}; 8 9use File::Spec; 10use lib File::Spec->catdir('t', 'lib'); 11use Test::More; 12BEGIN { 13 plan( 14 ${^TAINT} 15 ? (tests => 17) 16 : (skip_all => "A perl without taint support") 17 ); 18} 19 20use Scalar::Util qw/tainted/; 21 22my @Functions = qw(getcwd cwd fastcwd fastgetcwd 23 abs_path fast_abs_path 24 realpath fast_realpath 25 ); 26 27foreach my $func (@Functions) { 28 no strict 'refs'; 29 my $cwd; 30 eval { $cwd = &{'Cwd::'.$func} }; 31 is( $@, '', "$func() should not explode under taint mode" ); 32 ok( tainted($cwd), "its return value should be tainted" ); 33} 34 35# Previous versions of Cwd tainted $^O 36is !tainted($^O), 1, "\$^O should not be tainted"; 37