From 37d03f1b7ebf87ace91e504f6b0edba7cde15de8 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 23 Oct 2025 13:19:19 +0000 Subject: [PATCH] Bug 40659: Add Scrubber profile and scrub the contents of VIRTUALCARD template --- C4/Scrubber.pm | 34 ++++++++++++++++++++++++++++++++++ opac/opac-virtual-card.pl | 5 +++++ 2 files changed, 39 insertions(+) diff --git a/C4/Scrubber.pm b/C4/Scrubber.pm index 7197ac5fb89..8086c43ad9d 100644 --- a/C4/Scrubber.pm +++ b/C4/Scrubber.pm @@ -88,6 +88,40 @@ my %scrubbertypes = ( }, ], }, + opac => { + allow => [ + qw( + div span h1 h2 h3 h4 h5 h6 p br + ul ol li dl dt dd + a img svg + strong b em i u + hr + ) + ], + rules => [ + div => { + class => qr/^[\w\s\-_]+$/, + id => qr/^[\w\-_]+$/, + }, + + span => { + class => qr/^[\w\s\-_]+$/, + id => qr/^[\w\-_]+$/, + }, + 'svg' => { + 'id' => qr/^[\w\-_]+$/, + 'class' => qr/^[\w\s\-_]+$/, + 'data-barcode' => qr/^[\w\-_]+$/, + 'data-barcode-format' => qr/^[\w\-_]+$/, + }, + 'img' => { + 'src' => qr/^(?:https?:\/\/|\/)/i, + 'alt' => 1, + 'class' => qr/^[\w\s\-_]+$/, + 'id' => qr/^[\w\-_]+$/, + }, + ], + } ); sub new { diff --git a/opac/opac-virtual-card.pl b/opac/opac-virtual-card.pl index c44f84910d7..f09ca2559c7 100755 --- a/opac/opac-virtual-card.pl +++ b/opac/opac-virtual-card.pl @@ -76,6 +76,11 @@ my $content = C4::Letters::GetPreparedLetter( ) ); +my $scrubber = C4::Scrubber->new('opac'); +my $scrubbed = $scrubber->scrub( $content->{content} ); + +$content->{content} = $scrubbed; + $template->param( virtualcardview => 1, patron => $patron, -- 2.39.5