Bug 42136: prevent cgi, directory, and file plugins from use in user-entered templates

Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jacob O'Mara <Jacob.omara@openfifth.co.uk>
This commit is contained in:
David Cook 2026-03-20 06:10:22 +00:00 committed by Jacob O'Mara
parent 96beb660d5
commit 35cf33a18e
No known key found for this signature in database
3 changed files with 23 additions and 6 deletions

View File

@ -1797,9 +1797,14 @@ sub _process_tt {
my $use_template_cache = C4::Context->config('template_cache_dir') && defined $ENV{GATEWAY_INTERFACE};
my $template = Template->new(
{
EVAL_PERL => 0,
ABSOLUTE => 0,
RELATIVE => 0,
EVAL_PERL => 0,
ABSOLUTE => 0,
RELATIVE => 0,
PLUGINS => {
cgi => 'Koha::Template::Plugin::noop',
directory => 'Koha::Template::Plugin::noop',
file => 'Koha::Template::Plugin::noop',
},
PLUGIN_BASE => 'Koha::Template::Plugin',
COMPILE_EXT => $use_template_cache ? '.ttc' : '',
COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '',

View File

@ -0,0 +1,7 @@
package Koha::Template::Plugin::noop;
use Modern::Perl;
use base qw( Template::Plugin );
1;

View File

@ -58,9 +58,14 @@ sub process_tt {
my $tt = Template->new(
{
EVAL_PERL => 0,
ABSOLUTE => 0,
RELATIVE => 0,
EVAL_PERL => 0,
ABSOLUTE => 0,
RELATIVE => 0,
PLUGINS => {
cgi => 'Koha::Template::Plugin::noop',
directory => 'Koha::Template::Plugin::noop',
file => 'Koha::Template::Plugin::noop',
},
PLUGIN_BASE => 'Koha::Template::Plugin',
COMPILE_EXT => $use_template_cache ? '.ttc' : '',
COMPILE_DIR => $use_template_cache ? C4::Context->config('template_cache_dir') : '',