Lots of consting
[p5sagit/p5-mst-13.2.git] / t / op / taint.t
index cd445e4..26f9587 100755 (executable)
@@ -17,7 +17,7 @@ use Config;
 use File::Spec::Functions;
 
 BEGIN { require './test.pl'; }
-plan tests => 236;
+plan tests => 238;
 
 
 $| = 1;
@@ -205,7 +205,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 +1068,24 @@ 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;
+    }
+}