This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #82250] fix tainted (s)print format
[perl5.git] / pp_ctl.c
index ea7a2cd..44cf3c1 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -240,10 +240,10 @@ PP(pp_regcomp)
 
 #ifndef INCOMPLETE_TAINTS
     if (PL_tainting) {
-       if (PL_tainted)
+       if (PL_tainted) {
+           SvTAINTED_on((SV*)re);
            RX_EXTFLAGS(re) |= RXf_TAINTED;
-       else
-           RX_EXTFLAGS(re) &= ~RXf_TAINTED;
+       }
     }
 #endif
 
@@ -294,6 +294,7 @@ PP(pp_substcont)
 
        SvGETMAGIC(TOPs); /* possibly clear taint on $1 etc: #67962 */
 
+       /* See "how taint works" above pp_subst() */
        if (SvTAINTED(TOPs))
            cx->sb_rxtainted |= SUBST_TAINT_REPL;
        sv_catsv_nomg(dstr, POPs);
@@ -343,7 +344,8 @@ PP(pp_substcont)
            (void)SvPOK_only_UTF8(targ);
 
            /* update the taint state of various various variables in
-            * preparation for final exit */
+            * preparation for final exit.
+            * See "how taint works" above pp_subst() */
            if (PL_tainting) {
                if ((cx->sb_rxtainted & SUBST_TAINT_PAT) ||
                    ((cx->sb_rxtainted & (SUBST_TAINT_STR|SUBST_TAINT_RETAINT))
@@ -402,7 +404,8 @@ PP(pp_substcont)
     if (old != rx)
        (void)ReREFCNT_inc(rx);
     /* update the taint state of various various variables in preparation
-     * for calling the code block */
+     * for calling the code block.
+     * See "how taint works" above pp_subst() */
     if (PL_tainting) {
        if (RX_MATCH_TAINTED(rx)) /* run time pattern taint, eg locale */
            cx->sb_rxtainted |= SUBST_TAINT_PAT;