Forbid using tainted formats in printf and sprintf
[p5sagit/p5-mst-13.2.git] / t / op / regexp.t
index 678a46a..cce19fc 100755 (executable)
 #
 # \n in the tests are interpolated, as are variables of the form ${\w+}.
 #
+# Blanks lines are treated as PASSING tests to keep the line numbers
+# linked to the test number.
+#
 # If you want to add a regular expression test that can't be expressed
 # in this format, don't add it here: put it in op/pat.t instead.
+#
+# Note that columns 2,3 and 5 are all enclosed in double quotes and then
+# evalled; so something like a\"\x{100}$1 has length 3+length($1).
 
 BEGIN {
     chdir 't' if -d 't';
@@ -55,19 +61,22 @@ $| = 1;
 print "1..$numtests\n# $iters iterations\n";
 TEST:
 while (<TESTS>) {
+    if (!/\S/ || /^\s*#/) {
+        print "ok $. # (Blank line or comment)\n";
+        if (/\S/) { print $_ };
+        next;
+    }
     chomp;
     s/\\n/\n/g;
     ($pat, $subject, $result, $repl, $expect, $reason) = split(/\t/,$_,6);
     $input = join(':',$pat,$subject,$result,$repl,$expect);
     infty_subst(\$pat);
     infty_subst(\$expect);
-    $pat = "'$pat'" unless $pat =~ /^[:']/;
+    $pat = "'$pat'" unless $pat =~ /^[:'\/]/;
     $pat =~ s/(\$\{\w+\})/$1/eeg;
     $pat =~ s/\\n/\n/g;
-    $subject =~ s/(\$\{\w+\})/$1/eeg;
-    $subject =~ s/\\n/\n/g;
-    $expect =~ s/(\$\{\w+\})/$1/eeg;
-    $expect =~ s/\\n/\n/g;
+    $subject = eval qq("$subject");
+    $expect  = eval qq("$expect");
     $expect = $repl = '-' if $skip_amp and $input =~ /\$[&\`\']/;
     $skip = ($skip_amp ? ($result =~ s/B//i) : ($result =~ s/B//));
     $reason = 'skipping $&' if $reason eq  '' && $skip_amp;