Bugzilla – Attachment 195038 Details for
Bug 42047
Allow per-instance overrides for C4::Scrubber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 42047: Override configuration using html_scrubber.yaml
Bug-42047-Override-configuration-using-htmlscrubbe.patch (text/plain), 2.32 KB, created by
David Cook
on 2026-03-10 03:49:19 UTC
(
hide
)
Description:
Bug 42047: Override configuration using html_scrubber.yaml
Filename:
MIME Type:
Creator:
David Cook
Created:
2026-03-10 03:49:19 UTC
Size:
2.32 KB
patch
obsolete
>From 7000711159e8f7b4946055edea342cb4297b3c9c Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Tue, 10 Mar 2026 03:48:41 +0000 >Subject: [PATCH] Bug 42047: Override configuration using html_scrubber.yaml > >This patch allows you to override any of the C4::Scrubber >settings using a file called "html_scrubber.yaml" which >is to be located in the same directory as your koha-conf.xml file. > >This allows people to override existing configurations in >the event that they're not permissive enough (or are too permissive) > >e.g. The following YAML placed at /etc/koha/sites/kohadev/html_scrubber.yaml >would make the additional_content scrubber only allow "div" >--- >additional_content: > allow: ["div"] >--- > C4/Scrubber.pm | 46 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > >diff --git a/C4/Scrubber.pm b/C4/Scrubber.pm >index 2ab662983a7..103cfc51250 100644 >--- a/C4/Scrubber.pm >+++ b/C4/Scrubber.pm >@@ -23,8 +23,11 @@ use strict; > use warnings; > use Carp qw( croak ); > use HTML::Scrubber; >+use File::Basename qw( fileparse ); >+use YAML::XS; > > use C4::Context; >+use Koha::Config; > > my %scrubbertypes = ( > default => {}, # place holder, default settings are below as fallbacks in call to constructor >@@ -166,6 +169,49 @@ my %scrubbertypes = ( > }, > ); > >+override_default_settings( >+ { >+ settings => \%scrubbertypes, >+ } >+); >+ >+=head1 NAME >+ >+C4::Scrubber >+ >+=head1 API >+ >+=head2 Functions >+ >+=cut >+ >+=head3 override_default_settings >+ >+ >+=cut >+ >+sub override_default_settings { >+ my ($args) = @_; >+ my $settings = $args->{settings}; >+ if ($settings) { >+ my ( $koha_conf_filename, $config_dir ) = fileparse( Koha::Config->guess_koha_conf ); >+ my $filename = sprintf( "%s/html_scrubber.yaml", $config_dir ); >+ if ( $filename && -f $filename ) { >+ my $override_settings = YAML::XS::LoadFile($filename); >+ if ( $override_settings && ref $override_settings && ref $override_settings eq 'HASH' ) { >+ foreach my $type ( keys %$override_settings ) { >+ $settings->{$type} = $override_settings->{$type}; >+ } >+ } >+ } >+ } >+ return $settings; >+} >+ >+=head3 new >+ >+=cut >+ > sub new { > shift; # ignore our class we are wrapper > my $type = (@_) ? shift : 'default'; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 42047
: 195038