Bug 38365: Only get the nonce in templates if CSP is enabled

Signed-off-by: Lari Taskula <lari.taskula@hypernova.fi>
Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
David Cook 2026-02-18 01:11:35 +00:00 committed by Jonathan Druart
parent da52fd9c6f
commit c8bfd03386
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
1 changed files with 6 additions and 1 deletions

View File

@ -172,7 +172,12 @@ It should be cached by Koha::Middleware::ContentSecurityPolicy.
=cut
sub CSPNonce {
return Koha::ContentSecurityPolicy->new->get_nonce;
my $csp = Koha::ContentSecurityPolicy->new();
my $nonce;
if ( $csp->is_enabled ) {
$nonce = $csp->get_nonce;
}
return $nonce;
}
1;