Bug 31281: Use correct reply-to email when sending overdue mails
[koha.git] / C4 / Scrubber.pm
1 package C4::Scrubber;
2
3 # Copyright Liblime 2008
4 # Parts copyright sys-tech.net 2011
5 # Copyright PTFS Europe 2011
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21
22 use strict;
23 use warnings;
24 use Carp qw( croak );
25 use HTML::Scrubber;
26
27 use C4::Context;
28
29 my %scrubbertypes = (
30     default => {}, # place holder, default settings are below as fallbacks in call to constructor
31     tag     => {},                                               # uses defaults
32     comment => { allow => [qw( br b i em big small strong )], },
33     staff   => {
34         default => [ 1 => { '*' => 1 } ],
35         comment => 1,
36     },
37 );
38
39
40 sub new {
41     shift; # ignore our class we are wrapper
42     my $type = (@_) ? shift : 'default';
43     if ( !exists $scrubbertypes{$type} ) {
44         croak "New called with unrecognized type '$type'";
45     }
46     my $settings = $scrubbertypes{$type};
47     my $scrubber = HTML::Scrubber->new(
48         allow   => exists $settings->{allow} ? $settings->{allow} : [],
49         rules   => exists $settings->{rules} ? $settings->{rules} : [],
50         default => exists $settings->{default} ? $settings->{default} : [ 0 => { '*' => 0 } ],
51         comment => exists $settings->{comment} ? $settings->{comment} : 0,
52         process => 0,
53     );
54     return $scrubber;
55 }
56
57
58 1;
59 __END__
60
61 =head1 C4::Sanitize
62
63 Standardized wrapper with settings for building HTML::Scrubber tailored to various koha inputs.
64
65 The default is to scrub everything, leaving no markup at all.  This is compatible with the expectations
66 for Tags.
67
68 =head2 TODO: Add real perldoc
69
70 =cut
71