use strict;
use vars qw($VERSION);
-$VERSION = '3.45';
+$VERSION = '3.45_01';
my $xs_version = $VERSION;
$VERSION =~ tr/_//;
sub _tmpdir {
my $self = shift;
my @dirlist = @_;
- {
- no strict 'refs';
- if (${"\cTAINT"}) { # Check for taint mode on perl >= 5.8.0
- 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;
- }
+ my $taint = do { no strict 'refs'; ${"\cTAINT"} };
+ if ($taint) { # Check for taint mode on perl >= 5.8.0
+ 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 _;
$tmpdir = $_;
}
$tmpdir = $self->curdir unless defined $tmpdir;
$tmpdir = defined $tmpdir && $self->canonpath($tmpdir);
+ if ( $tmpdir eq '.' ) {
+ # See [perl #120593] for the full details
+ # If possible, return a full path, rather than '.', but
+ # we have to avoid returning a tainted value, so we jump
+ # through some hoops.
+ ($tmpdir) = grep {
+ $taint ? ! Scalar::Util::tainted($_) :
+ $] < 5.007 ? eval { eval('1'.substr $_,0,0) } : 1
+ } $self->rel2abs($tmpdir), $tmpdir;
+ }
return $tmpdir;
}
use strict;
-use Test::More tests => 7;
+use Test::More tests => 8;
# Grab all of the plain routines from File::Spec
use File::Spec;
isn't $tmpdir2, $tmpdir1, "$_->tmpdir works with changing env";
}
}
+
+ok(
+ File::Spec->file_name_is_absolute(File::Spec->tmpdir()),
+ "tmpdir() always returns an absolute path"
+);