summaryrefslogtreecommitdiff
path: root/t/loc_tools.pl
diff options
context:
space:
mode:
authorTomasz Konojacki <me@xenu.pl>2018-01-20 23:54:34 +0100
committerKarl Williamson <khw@cpan.org>2018-01-20 17:49:19 -0700
commitb3c872ebe7541431109f07330ab5123db843dea1 (patch)
tree5c3b933eb0ed830d24bb407f16f842b4cfcc142d /t/loc_tools.pl
parent85a8548711e75aede72b0a6207a64963e01e198e (diff)
downloadperl-b3c872ebe7541431109f07330ab5123db843dea1.tar.gz
loc_tools.pl: untaint _source_location's return value and fix a warning
Some of our tests are running with -T and it turns out that something in File::Spec::Unix is the tainting the return value of _source_location(). Additionally, when warnings are enabled globally (with either $^W or -W), not passing the last argument (filename) to File::Spec->catpath results in an undefined variable warning.
Diffstat (limited to 't/loc_tools.pl')
-rw-r--r--t/loc_tools.pl6
1 files changed, 4 insertions, 2 deletions
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index fbe7242b1e..4f0ae2ba17 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -494,11 +494,13 @@ sub _source_location {
my $caller_filename = (caller)[1];
- return File::Spec->rel2abs(
+ my $loc = File::Spec->rel2abs(
File::Spec->catpath(
- (File::Spec->splitpath($caller_filename))[0, 1]
+ (File::Spec->splitpath($caller_filename))[0, 1], ''
)
);
+
+ return ($loc =~ /^(.*)$/)[0]; # untaint
}
1