rss2html/lib/Rss2Html/Scrubber.pm

32 lines
546 B
Perl
Raw Normal View History

package Rss2Html::Scrubber;
use warnings;
use strict;
use parent 'HTML::Scrubber';
sub new {
my ($class, %options) = @_;
my $self = HTML::Scrubber->new();
$self->deny(qw(link));
2018-03-29 18:37:22 +02:00
$self->allow(qw(p a em strong b i ul ol li dl dt dd br blockquote));
my %rules = (
a => {
href => qr{^https?://}i,
'*' => 0,
},
);
if ($options{allow_img}) {
$rules{img} = {
src => qr{^https?://}i,
alt => 1,
'*' => 0,
},
}
$self->rules(
%rules
);
bless $self, $class;
return $self;
}
1;