From 8e165e12797c5979a03c3319969bccf5d941ee43 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Jun 2018 17:17:43 -0300 Subject: [PATCH] AutoEscaping - TT html filters for x in 1 2 3 4 5; do time perl benchmark_AutoEscaping.pl; done perl benchmark_AutoEscaping.pl 0.30s user 0.09s system 95% cpu 0.414 total perl benchmark_AutoEscaping.pl 0.27s user 0.02s system 97% cpu 0.295 total perl benchmark_AutoEscaping.pl 0.28s user 0.02s system 99% cpu 0.307 total perl benchmark_AutoEscaping.pl 0.30s user 0.02s system 98% cpu 0.320 total perl benchmark_AutoEscaping.pl 0.27s user 0.02s system 99% cpu 0.290 total https://bugs.koha-community.org/show_bug.cgi?id=20975 --- C4/Templates.pm | 2 ++ benchmark_AutoEscaping.pl | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt | 6 ++++++ mainpage.pl | 9 +++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/C4/Templates.pm b/C4/Templates.pm index 343a374199..806f5dc189 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -5,6 +5,7 @@ use warnings; use Carp; use CGI qw ( -utf8 ); use List::MoreUtils qw/ any uniq /; +use Template::Stash::AutoEscaping; # Copyright 2009 Chris Cormack and The Koha Dev Team # @@ -72,6 +73,7 @@ sub new { COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '', INCLUDE_PATH => \@includes, FILTERS => {}, + STASH => Template::Stash::AutoEscaping->new, ENCODING => 'UTF-8', } ) or die Template->error(); diff --git a/benchmark_AutoEscaping.pl b/benchmark_AutoEscaping.pl index 63b258d9bd..6ff8a174e0 100644 --- a/benchmark_AutoEscaping.pl +++ b/benchmark_AutoEscaping.pl @@ -31,7 +31,7 @@ __DATA__ [% pouet %]
[% FOR l IN loop %] - [% l.foo %] [% l.bar %] + [% l.foo | html %] [% l.bar | html %]
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 8a97473edc..9758aafb8d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -34,6 +34,12 @@ [% END %] +
+ [% FOR l IN loop %] + [% l.foo %] [% l.bar %] +
+ [% END %] +
diff --git a/mainpage.pl b/mainpage.pl index da6aaee924..4bdeaec2e3 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -44,6 +44,15 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user( } ); +my @loop; +for my $i ( 0 .. 10000 ) { + push @loop, { + foo => 'my foo', + bar => 'my bar', + }; +} +$template->param( loop => \@loop ); + my $homebranch; if (C4::Context->userenv) { $homebranch = C4::Context->userenv->{'branch'}; -- 2.11.0