32 lines
546 B
Perl
32 lines
546 B
Perl
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));
|
|
$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;
|