diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-02-27 16:13:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-02-27 16:13:05 +0000 |
commit | 613de57f1df271b4819b04c5522a963f3b1f0f50 (patch) | |
tree | c21428aee6ebaefefc85a8761d6e5c553ba14fe7 /t/test.pl | |
parent | dd3874d7bd7bd60c75dc2e7efa06380d81f13287 (diff) | |
download | perl-613de57f1df271b4819b04c5522a963f3b1f0f50.tar.gz |
Move all the de-tainting logic for runperl into test.pl.
p4raw-id: //depot/perl@27345
Diffstat (limited to 't/test.pl')
-rw-r--r-- | t/test.pl | 34 |
1 files changed, 27 insertions, 7 deletions
@@ -481,16 +481,36 @@ sub runperl { die "test.pl:runperl() does not take a hashref" if ref $_[0] and ref $_[0] eq 'HASH'; my $runperl = &_create_runperl; + my $result; + if (${^TAINT}) { - # We will assume that if you're running under -T, you really mean - # to run a fresh perl, so we'll brute force launder everything for - # you - foreach ($runperl, $ENV{PATH}) { - $_ =~ /(.*)/s; - $_ = $1; + # We will assume that if you're running under -T, you really mean to + # run a fresh perl, so we'll brute force launder everything for you + my $sep; + + eval "require Config; Config->import"; + if ($@) { + warn "test.pl had problems loading Config: $@"; + $sep = ':'; + } else { + $sep = $Config{path_sep}; } + + my @keys = grep {exists $ENV{$_}} qw(CDPATH IFS ENV BASH_ENV); + local @ENV{@keys} = (); + # Untaint, plus take out . and empty string: + $ENV{PATH} =~ /(.*)/s; + local $ENV{PATH} + = join $sep, grep {$_ ne "" and $_ ne "."} + split quotemeta ($sep), $1; + + $runperl =~ /(.*)/s; + $runperl = $1; + + $result = `$runperl`; + } else { + $result = `$runperl`; } - my $result = `$runperl`; $result =~ s/\n\n/\n/ if $is_vms; # XXX pipes sometimes double these return $result; } |