tests are expected to fail if dirfd () does not exist
[p5sagit/p5-mst-13.2.git] / t / op / taint.t
index cd445e4..7f9d06e 100755 (executable)
@@ -17,7 +17,7 @@ use Config;
 use File::Spec::Functions;
 
 BEGIN { require './test.pl'; }
-plan tests => 236;
+plan tests => 244;
 
 
 $| = 1;
@@ -134,6 +134,23 @@ my $TEST = catfile(curdir(), 'TEST');
 {
     $ENV{'DCL$PATH'} = '' if $Is_VMS;
 
+    if ($Is_MSWin32 && $Config{ccname} =~ /bcc32/ && ! -f 'cc3250mt.dll') {
+       my $bcc_dir;
+       foreach my $dir (split /$Config{path_sep}/, $ENV{PATH}) {
+           if (-f "$dir/cc3250mt.dll") {
+               $bcc_dir = $dir and last;
+           }
+       }
+       if (defined $bcc_dir) {
+           require File::Copy;
+           File::Copy::copy("$bcc_dir/cc3250mt.dll", '.') or
+               die "$0: failed to copy cc3250mt.dll: $!\n";
+           eval q{
+               END { unlink "cc3250mt.dll" }
+           };
+       }
+    }
+
     $ENV{PATH} = '';
     delete @ENV{@MoreEnv};
     $ENV{TERM} = 'dumb';
@@ -205,7 +222,7 @@ my $TEST = catfile(curdir(), 'TEST');
        test $@ =~ /^Insecure \$ENV{DCL\$PATH}/, $@;
        SKIP: {
             skip q[can't find world-writeable directory to test DCL$PATH], 2
-              if $tmp;
+              unless $tmp;
 
            $ENV{'DCL$PATH'} = $tmp;
            test eval { `$echo 1` } eq '';
@@ -1068,3 +1085,53 @@ TERNARY_CONDITIONALS: {
     test $result eq "The Fabulous Johnny Cash";
     test !tainted( $result );
 }
+
+{
+    # rt.perl.org 5900  $1 remains tainted if...
+    # 1) The regular expression contains a scalar variable AND
+    # 2) The regular expression appears in an elsif clause
+
+    my $foo = "abcdefghi" . $TAINT;
+
+    my $valid_chars = 'a-z';
+    if ( $foo eq '' ) {
+    }
+    elsif ( $foo =~ /([$valid_chars]+)/o ) {
+        test not tainted $1;
+    }
+
+    if ( $foo eq '' ) {
+    }
+    elsif ( my @bar = $foo =~ /([$valid_chars]+)/o ) {
+        test not any_tainted @bar;
+    }
+}
+
+# at scope exit, a restored localised value should have its old
+# taint status, not the taint status of the current statement
+
+{
+    our $x99 = $^X;
+    test tainted $x99;
+
+    $x99 = '';
+    test not tainted $x99;
+
+    my $c = do { local $x99; $^X };
+    test not tainted $x99;
+}
+{
+    our $x99 = $^X;
+    test tainted $x99;
+
+    my $c = do { local $x99; '' };
+    test tainted $x99;
+}
+
+# an mg_get of a tainted value during localization shouldn't taint the
+# statement
+
+{
+    eval { local $0, eval '1' };
+    test $@ eq '';
+}