Commit 054c3983d5 for perl
commit 054c3983d5167ed3496e5fb24e6442f19b93c560
Author: Richard Leach <rich+perl@hyphen-dash-hyphen.info>
Date: Tue Nov 10 23:43:34 2026 +0000
pp_subst(cont) - remove dead runtime tainting checks
This commit removes a number of checks in `pp_subst` and `pp_substcont`
having this sort of pattern:
/* run time pattern taint, eg locale */
if (UNLIKELY(RXp_MATCH_TAINTED(prog)))
rxtainted |= SUBST_TAINT_PAT;
Prior to v5.20, the result of some regex nodes could depend upon the
locale in effect at the point of regex execution, with the match
tainted when such a node was used. This is what these tests were
checking for.
However, https://github.com/Perl/perl5/commit/63baef57 made taint
check a compile time rather than runtime behaviour, following the
discussion at https://rt.perl.org/Ticket/Display.html?id=120675.
These checks are therefore redundant; the taintedness of the match
does not change from one execution to another.
diff --git a/pp_ctl.c b/pp_ctl.c
index 06fa2f3392..e35f84992b 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -264,8 +264,6 @@ PP(pp_substcont)
else
sv_catpvn_nomg(dstr, s, cx->sb_strend - s);
}
- if (RX_MATCH_TAINTED(rx)) /* run time pattern taint, eg locale */
- cx->sb_rxtainted |= SUBST_TAINT_PAT;
if (pm->op_pmflags & PMf_NONDESTRUCT) {
retval = dstr;
diff --git a/pp_hot.c b/pp_hot.c
index da20afcf80..0f078ffd39 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5592,8 +5592,6 @@ PP(pp_subst)
if (once) {
char *d, *m;
- if (RXp_MATCH_TAINTED(prog)) /* run time pattern taint, eg locale */
- rxtainted |= SUBST_TAINT_PAT;
m = orig + RXp_OFFS_START(prog,0);
d = orig + RXp_OFFS_END(prog,0);
s = orig;
@@ -5630,9 +5628,6 @@ PP(pp_subst)
SSize_t i;
if (UNLIKELY(iters++ > maxiters))
DIE(aTHX_ "Substitution loop");
- /* run time pattern taint, eg locale */
- if (UNLIKELY(RXp_MATCH_TAINTED(prog)))
- rxtainted |= SUBST_TAINT_PAT;
m = RXp_OFFS_START(prog,0) + orig;
if ((i = m - s)) {
if (s != d)
@@ -5682,8 +5677,6 @@ PP(pp_subst)
#ifdef PERL_ANY_COW
have_a_cow:
#endif
- if (RXp_MATCH_TAINTED(prog)) /* run time pattern taint, eg locale */
- rxtainted |= SUBST_TAINT_PAT;
repl = dstr;
s = RXp_OFFS_START(prog,0) + orig;
@@ -5779,8 +5772,6 @@ PP(pp_subst)
{
if (UNLIKELY(iters++ > maxiters))
DIE(aTHX_ "Substitution loop");
- if (UNLIKELY(RXp_MATCH_TAINTED(prog)))
- rxtainted |= SUBST_TAINT_PAT;
if (RXp_MATCH_COPIED(prog) && RXp_SUBBEG(prog) != orig) {
char *old_s = s;
char *old_orig = orig;
@@ -5826,8 +5817,6 @@ PP(pp_subst)
{
if (UNLIKELY(iters++ > maxiters))
DIE(aTHX_ "Substitution loop");
- if (UNLIKELY(RXp_MATCH_TAINTED(prog)))
- rxtainted |= SUBST_TAINT_PAT;
if (RXp_MATCH_COPIED(prog) && RXp_SUBBEG(prog) != orig) {
char *old_s = s;
char *old_orig = orig;