diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | dist/Cwd/lib/File/Spec/Unix.pm | 7 | ||||
-rw-r--r-- | dist/Cwd/t/Spec-taint.t | 17 |
3 files changed, 23 insertions, 2 deletions
@@ -3080,6 +3080,7 @@ dist/Cwd/t/cwd.t See if Cwd works dist/Cwd/t/Functions.t See if File::Spec::Functions works dist/Cwd/t/rel2abs2rel.t See if File::Spec->rel2abs/abs2rel works dist/Cwd/t/Spec.t See if File::Spec works +dist/Cwd/t/Spec-taint.t See if File::Spec works with taint dist/Cwd/t/taint.t See if Cwd works with taint dist/Cwd/t/tmpdir.t See if File::Spec->tmpdir() works dist/Cwd/t/win32.t See if Cwd works on Win32 diff --git a/dist/Cwd/lib/File/Spec/Unix.pm b/dist/Cwd/lib/File/Spec/Unix.pm index 9f024e00be..b3481476a8 100644 --- a/dist/Cwd/lib/File/Spec/Unix.pm +++ b/dist/Cwd/lib/File/Spec/Unix.pm @@ -3,7 +3,7 @@ package File::Spec::Unix; use strict; use vars qw($VERSION); -$VERSION = '3.34'; +$VERSION = '3.35'; $VERSION = eval $VERSION; =head1 NAME @@ -135,7 +135,7 @@ writable: $ENV{TMPDIR} /tmp -Since perl 5.8.0, if running under taint mode, and if $ENV{TMPDIR} +If running under taint mode, and if $ENV{TMPDIR} is tainted, it is not used. =cut @@ -151,6 +151,9 @@ sub _tmpdir { require Scalar::Util; @dirlist = grep { ! Scalar::Util::tainted($_) } @dirlist; } + elsif ($] < 5.007) { # No ${^TAINT} before 5.8 + @dirlist = grep { eval { eval('1'.substr $_,0,0) } } @dirlist; + } } foreach (@dirlist) { next unless defined && -d && -w _; diff --git a/dist/Cwd/t/Spec-taint.t b/dist/Cwd/t/Spec-taint.t new file mode 100644 index 0000000000..ef4f1ee3f2 --- /dev/null +++ b/dist/Cwd/t/Spec-taint.t @@ -0,0 +1,17 @@ +#!./perl -Tw +# Testing File::Spec under taint mode. + +use strict; + +chdir 't' unless $ENV{PERL_CORE}; + +use File::Spec; +use lib File::Spec->catdir('t', 'lib'); +use Test::More tests => 2; + +use Scalar::Util qw/tainted/; + +my $ret; +eval { $ret = File::Spec->tmpdir }; +is( $@, '', "tmpdir should not explode under taint mode" ); +ok( !tainted($ret), "its return value should not be tainted" ); |