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