[Rt-commit] rt branch, 4.4/escape-functions-in-templates, created. rt-4.2.12-505-g68a25d8
? sunnavy
sunnavy at bestpractical.com
Thu Nov 5 15:36:13 EST 2015
The branch, 4.4/escape-functions-in-templates has been created
at 68a25d87518287319e7d4fc53a11b008e9134827 (commit)
- Log -----------------------------------------------------------------
commit 68a25d87518287319e7d4fc53a11b008e9134827
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Nov 6 04:24:31 2015 +0800
export EscapeURI and EscapeHTML functions to templates
we have them in RT::Interface::Web already, so we can just reuse them here.
Fixes: I#31442
diff --git a/lib/RT/Template.pm b/lib/RT/Template.pm
index 4b55443..c5b3acd 100644
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@ -78,6 +78,21 @@ use Text::Template;
use MIME::Entity;
use MIME::Parser;
use Scalar::Util 'blessed';
+use RT::Interface::Web;
+
+our $TemplatePrepend = <<'EOF';
+no warnings 'redefine';
+sub EscapeURI {
+ my $str = shift;
+ RT::Interface::Web::EscapeURI(\$str);
+ return $str;
+}
+sub EscapeHTML {
+ my $str = shift;
+ RT::Interface::Web::EscapeHTML(\$str);
+ return $str;
+}
+EOF
sub _Accessible {
my $self = shift;
@@ -533,6 +548,7 @@ sub _ParseContentPerl {
my $template = Text::Template->new(
TYPE => 'STRING',
SOURCE => $args{Content},
+ PREPEND => $TemplatePrepend,
);
my ($ok) = $template->compile;
unless ($ok) {
@@ -569,6 +585,7 @@ sub _ParseContentSimple {
my $template = Text::Template->new(
TYPE => 'STRING',
SOURCE => $args{Content},
+ PREPEND => $TemplatePrepend,
);
my ($ok) = $template->compile;
return ( undef, $self->loc('Template parsing error: [_1]', $Text::Template::ERROR) ) if !$ok;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list