1 package SL::HTML::Restrict;
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) };
12 return HTML::Restrict->new(rules => $params{allowed_tags});
24 SL::HTML::Restrict - Restrict HTML tags to set of allowed tags
28 my $cleaner = SL::HTML::Restrict->create;
29 my $cleaned = $cleaner->process($unsafe_html);
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:
37 C<b br div em i li ol p s strike strong sub sup u ul>
39 This list can be overwritten.
45 =item C<create [%params]>
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).
51 Returns an instance of L<HTML::Restrict>.
61 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>