Changeset 2063

Show
Ignore:
Timestamp:
02/25/09 08:58:01
Author:
jesse
Message:

Added support for a url whitelist for enclosures that FindEnclosures? should find

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Filter/FindEnclosures.pm

    r1954 r2063  
    122122    } 
    123123 
     124    return unless ($self->url_whitelisted($url)); 
     125 
    124126    if ($url) { 
    125127        Plagger->context->log(info => "Found enclosure $url"); 
     
    131133} 
    132134 
     135 
    133136sub add_enclosure { 
    134137    my($self, $entry, $tag, $attr, $opt) = @_; 
    135138    $opt ||= {}; 
     139 
     140    return unless ($self->url_whitelisted($tag->[1]->{$attr})); 
    136141 
    137142    if ($self->is_enclosure($tag, $attr, $opt->{type})) { 
     
    163168} 
    164169 
     170sub url_whitelisted { 
     171    my $self = shift; 
     172    my $url = shift; 
     173 
     174    if (my $regex = $self->conf->{enclosure_whitelist} ){ 
     175        return unless ($url =~ qr/$regex/); 
     176    } 
     177    return 1; 
     178} 
     179 
    165180sub fetch_content { 
    166181    my($self, $url) = @_; 
     
    227242requests. 
    228243 
     244=head1 USAGE 
     245 
     246  - module: Filter::FindEnclosures 
     247    config: 
     248      enclosure_whitelist: (?:jpg|png|gif) 
     249 
    229250=head1 AUTHOR 
    230251