Skip Menu |

This queue is for tickets about the Template-Toolkit CPAN distribution.

Report information
The Basics
Id: 48654
Status: resolved
Priority: 0/
Queue: Template-Toolkit

People
Owner: Nobody in particular
Requestors: bbaetz [...] gmail.com
Cc: LpSolit [...] aim.com
AdminCc:

Bug Information
Severity: Important
Broken in: 2.22
Fixed in: (no value)



Subject: Using TT causes unrelated unicode string to become tainted when regex substitution applied
This is distilled from https://bugzilla.mozilla.org/show_bug.cgi?id=509794 This is a really odd bug. On perl 5.8.8 (not 5.10.0), with TT 2.22 (and earlier versions) with the XS stash, using Template Toolkit causes a totally unrelated unicode string to become tainted when a regex substitution is applied to it. Run the attached file as |perl -wT test.cgi comment=test| to see this. The guts of the script is: my $message = ''; my $ttext = <<EOT; [% USE CGI %] [% IF CGI.param("comment") && CGI.param("comment").length > 0 %] [% END %] EOT $template->process(\$ttext, {}, \$message); my $a = 'x'; my $b = "test\x{2012}unicode"; my $summary = $a . ':' . $b; # Running the following line causes $summary to become tainted $summary =~ s/^[^:]+://; The following options work around the bug: * commenting out the call to $template->process * Using the pure-perl stash ($Template::Config::Stash = 'Template::Stash') * Not passing in a comment parameter to the script * Changing the template to any of: - [% IF CGI.param("comment").defined && CGI.param("comment").length > 0 %] - Remove the IF, ie just having [% CGI.param("comment") && CGI.param("comment").length > 0 %] - [% comment = CGI.param("comment") %][% IF comment && comment.length > 0 %] * Tweaking the regexp in various ways * Not generating $summary through string concatenation. Its possible that this is a perl bug, since it doesn't happen in 5.10, but not using the XS stash also fixes it, so it could be TT. Either way, its really odd The failing machine is centos 5.3 (32 bit), and the working machine is F11 (x86_64)
Subject: test.cgi
Download test.cgi
application/octet-stream 853b

Message body not shown because it is not plain text.

Actually, I *can* repro this in 5.10 on F11 - I was typoing the 'comment' param so it didn't trigger.
From: LpSolit [...] aim.com
Show quoted text
> Actually, I *can* repro this in 5.10
I can also reproduce this with Perl 5.10.0 + TT 2.22, but I cannot using Perl 5.10.1 RC1 + TT 2.22. So it seems to be a Perl bug rather than a TT bug.
Ticket migrated to github as https://github.com/abw/Template2/issues/146