diff options
author | Chip Salzenberg <chip@atlantic.net> | 1996-12-25 21:42:02 +1200 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1996-12-28 06:22:00 +1200 |
commit | 13f57bf83929943c057a8fe71d4513271a958bcc (patch) | |
tree | 064d77fdf710c2a0e486a7e15f1411f866784887 /mg.c | |
parent | 3ed26a2c26e4f1468588c483e9e86eae4e74f24f (diff) | |
download | perl-13f57bf83929943c057a8fe71d4513271a958bcc.tar.gz |
Fix {,un}tainting of $1 etc. when C<use locale>
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 46 |
1 files changed, 20 insertions, 26 deletions
@@ -26,14 +26,6 @@ # endif #endif -#define TAINT_FROM_REGEX(sv,rx) \ - if ((rx)->exec_tainted) { \ - TAINT; \ - SvTAINTED_on(sv); \ - } \ - else \ - SvTAINTED_off(sv); - /* * Use the "DESTRUCTOR" scope cleanup to reinstate magic. */ @@ -298,15 +290,14 @@ MAGIC *mg; case '+': if (curpm && (rx = curpm->op_pmregexp)) { paren = rx->lastparen; - if (!paren) - return 0; - goto getparen; + if (paren) + goto getparen; } return 0; break; case '`': if (curpm && (rx = curpm->op_pmregexp)) { - if ((s = rx->subbeg)) { + if ((s = rx->subbeg) && rx->startp[0]) { i = rx->startp[0] - s; if (i >= 0) return i; @@ -315,9 +306,10 @@ MAGIC *mg; return 0; case '\'': if (curpm && (rx = curpm->op_pmregexp)) { - if ((s = rx->endp[0])) { - TAINT_IF(rx->exec_tainted); - return (STRLEN) (rx->subend - s); + if (rx->subend && (s = rx->endp[0])) { + i = rx->subend - s; + if (i >= 0) + return 0; } } return 0; @@ -414,9 +406,16 @@ MAGIC *mg; (t = rx->endp[paren])) { i = t - s; + getrx: if (i >= 0) { + bool was_tainted; + if (tainting) { + was_tainted = tainted; + tainted = FALSE; + } sv_setpvn(sv,s,i); - TAINT_FROM_REGEX(sv,rx); + if (tainting) + tainted = was_tainted || rx->exec_tainted; break; } } @@ -433,23 +432,18 @@ MAGIC *mg; break; case '`': if (curpm && (rx = curpm->op_pmregexp)) { - if ((s = rx->subbeg)) { + if ((s = rx->subbeg) && rx->startp[0]) { i = rx->startp[0] - s; - if (i >= 0) { - sv_setpvn(sv,s,i); - TAINT_FROM_REGEX(sv,rx); - break; - } + goto getrx; } } sv_setsv(sv,&sv_undef); break; case '\'': if (curpm && (rx = curpm->op_pmregexp)) { - if ((s = rx->endp[0])) { - sv_setpvn(sv,s, rx->subend - s); - TAINT_FROM_REGEX(sv,rx); - break; + if (rx->subend && (s = rx->endp[0])) { + i = rx->subend - s; + goto getrx; } } sv_setsv(sv,&sv_undef); |