Release 3.6.1
[kivitendo-erp.git] / SL / HTML / Restrict.pm
1 package SL::HTML::Restrict;
2
3 use strict;
4 use warnings;
5
6 use HTML::Restrict ();
7
8 sub create {
9   my ($class, %params)    = @_;
10   $params{allowed_tags} //= { map { ($_ => ['/']) } qw(b strong i em u ul ol li sub sup s strike br p div) };
11
12   return HTML::Restrict->new(rules => $params{allowed_tags});
13 }
14
15 1;
16 __END__
17
18 =pod
19
20 =encoding utf8
21
22 =head1 NAME
23
24 SL::HTML::Restrict - Restrict HTML tags to set of allowed tags
25
26 =head1 SYNOPSIS
27
28   my $cleaner = SL::HTML::Restrict->create;
29   my $cleaned = $cleaner->process($unsafe_html);
30
31 =head1 DESCRIPTION
32
33 Often you want to allow a fixed set of well-known HTML tags to be used
34 – but nothing else. This is a thin wrapper providing a default set of
35 the following elements:
36
37 C<b br div em i li ol p s strike strong sub sup u ul>
38
39 This list can be overwritten.
40
41 =head1 FUNCTIONS
42
43 =over 4
44
45 =item C<create [%params]>
46
47 Creates and returns a new instance of L<HTML::Restrict>. The optional
48 parameter C<allowed_tags> must be an array reference of allowed tag
49 names. If it's missing then the default set will be used (see above).
50
51 Returns an instance of L<HTML::Restrict>.
52
53 =back
54
55 =head1 BUGS
56
57 Nothing here yet.
58
59 =head1 AUTHOR
60
61 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
62
63 =cut