From 63097f365a237dc9c5e8bc8cf96d7f9ea6cf5d63 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 3 Apr 2026 13:53:52 +0200 Subject: [PATCH] Bug 42136: Add tests Signed-off-by: Jonathan Druart Signed-off-by: Jacob O'Mara --- t/Template/Utils.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/Template/Utils.t b/t/Template/Utils.t index 0f1a9ed307..a22683c53b 100755 --- a/t/Template/Utils.t +++ b/t/Template/Utils.t @@ -18,7 +18,8 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 3; +use Test::NoWarnings; +use Test::More tests => 4; use utf8; @@ -58,3 +59,24 @@ subtest 'Plugin related tests' => sub { "Processing template toolkit with a Koha plugin works" ); }; + +subtest 'Security-related tests' => sub { + plan tests => 2; + + is( + Koha::TemplateUtils::process_tt( + q{[% USE dir = Directory('/') ~%] +[% FOREACH entry IN dir.list ~%] +

[% entry.abs %]

+[% END %]}, + ), + q{}, + "Plugins not allowed for User-entered TT" + ); + + is( + Koha::TemplateUtils::process_tt(q{[% USE raw %][% 'foo' | $raw %]}), + q{foo}, + "Koha plugins are still available" + ); +};