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