p4raw-id: //depot/perl@25081
Perl_magic_settaint(pTHX_ SV *sv, MAGIC *mg)
{
PERL_UNUSED_ARG(sv);
- if (PL_tainted)
- mg->mg_len |= 1;
- else
- mg->mg_len &= ~1;
+ /* update taint status unless we're restoring at scope exit */
+ if (PL_localizing != 2) {
+ if (PL_tainted)
+ mg->mg_len |= 1;
+ else
+ mg->mg_len &= ~1;
+ }
return 0;
}
use File::Spec::Functions;
BEGIN { require './test.pl'; }
-plan tests => 238;
+plan tests => 243;
$| = 1;
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;
+}
+