This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/taint.t: Add test
authorKarl Williamson <khw@cpan.org>
Wed, 15 Aug 2018 23:07:51 +0000 (17:07 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 15 Feb 2019 05:12:44 +0000 (22:12 -0700)
t/op/taint.t

index adb6907..ca67024 100644 (file)
@@ -17,7 +17,7 @@ BEGIN {
 use strict;
 use Config;
 
-plan tests => 1041;
+plan tests => 1042;
 
 $| = 1;
 
@@ -2380,6 +2380,22 @@ end
     eval { "A" =~ /\p{$prop}/};
     like($@, qr/Insecure user-defined property "IsA" in regex/,
            "user-defined property: tainted case");
+
+}
+
+{
+
+    local $ENV{XX} = '\p{IsB}';   # Making it an environment variable taints it
+
+    fresh_perl_like(<<'EOF',
+        BEGIN { $re = qr/$ENV{XX}/; }
+
+        sub IsB { "42" };
+        "B" =~ $re
+EOF
+     qr/Insecure user-defined property \\p\{main::IsB\}/,
+     { switches => [ "-T" ] },
+    "user-defined property; defn not known until runtime, tainted case");
 }
 
 {