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