2017-06-12 21:29:41 +02:00
|
|
|
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));
|
2017-06-12 21:29:41 +02:00
|
|
|
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;
|