[Rt-commit] rt branch, 4.4/escape-functions-in-templates, created. rt-4.2.12-505-g7b36d07

? sunnavy sunnavy at bestpractical.com
Thu Nov 5 23:19:57 EST 2015


The branch, 4.4/escape-functions-in-templates has been created
        at  7b36d07c9287b7ce6975bf1057e56a48043dfb55 (commit)

- Log -----------------------------------------------------------------
commit 7b36d07c9287b7ce6975bf1057e56a48043dfb55
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..b30eaaa 100644
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@ -78,6 +78,7 @@ use Text::Template;
 use MIME::Entity;
 use MIME::Parser;
 use Scalar::Util 'blessed';
+use RT::Interface::Web;
 
 sub _Accessible {
     my $self = shift;
@@ -501,6 +502,16 @@ sub _ParseContent {
     }
 
     if ($self->Type eq 'Perl') {
+        $args{'EscapeURI'} = sub {
+            my $str = shift;
+            RT::Interface::Web::EscapeURI( \$str );
+            return $str;
+        };
+        $args{'EscapeHTML'} = sub {
+            my $str = shift;
+            RT::Interface::Web::EscapeHTML( \$str );
+            return $str;
+        };
         return $self->_ParseContentPerl(
             Content      => $content,
             TemplateArgs => \%args,

-----------------------------------------------------------------------


More information about the rt-commit mailing list