NAME
Koha::QA::Security::TemplateFilters - Detect and fix missing filters in Template Toolkit files
SYNOPSIS
use Koha::QA::Security::TemplateFilters;
# With a file
my $checker = Koha::QA::Security::TemplateFilters->new({file => $file_path});
# Or with content directly
my $checker = Koha::QA::Security::TemplateFilters->new({content => $template_content});
my $is_valid = $checker->check;
my @errors = $checker->errors;
# Get fixed content
my $fixed_content = $checker->fix;
DESCRIPTION
This module provides functionality to detect and automatically fix missing filters in Template Toolkit template files. It helps ensure that variables are properly escaped to prevent XSS vulnerabilities.
METHODS
new
my $checker = Koha::QA::Security::TemplateFilters->new({file => $file_path});
Creates a new TemplateFilters checker instance.
check
my $is_valid = $checker->check;
Checks the file for missing filters.
errors
my @errors = $checker->errors;
Returns array of error hashrefs, each containing: - error: The type of error (asset_must_be_raw, missing_filter, wrong_html_filter, extra_filter_not_needed) - line: The line where the error was found - line_number: The line number where the error was found
fix
my $fixed_content = $checker->fix;
Returns the content with the correct (guessed) filters applied.
AUTHORS
Jonathan Druart <jonathan.druart@bugs.koha-community.org>
COPYRIGHT
Copyright 2026 Koha Development Team
LICENSE
This file is part of Koha.
Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.