File tree Expand file tree Collapse file tree 7 files changed +65
-9
lines changed Expand file tree Collapse file tree 7 files changed +65
-9
lines changed Original file line number Diff line number Diff line change @@ -62,3 +62,7 @@ Makefile.PL
6262META.json
6363t/19-double3.t
6464t/samples/rss10-double2.xml
65+ t/20-no-enclosures.t
66+ t/21-rss2-permalinks.t
67+ t/samples/rss20-p.xml
68+
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ use Module::Pluggable search_path => "XML::Feed::Format",
1212 require => 1,
1313 sub_name => ' formatters' ;
1414
15- our $VERSION = ' 0.45 ' ;
15+ our $VERSION = ' 0.46 ' ;
1616our $MULTIPLE_ENCLOSURES = 0;
1717our @formatters ;
1818BEGIN {
@@ -355,13 +355,13 @@ the current format of the I<$feed> object.
355355
356356=over 4
357357
358- =item C<$XML::Feed::RSS::PREFERRED_PARSER >
358+ =item C<$XML::Feed::Format:: RSS::PREFERRED_PARSER >
359359
360360If you want to use another RSS parser class than XML::RSS (default), you can
361- change the class by setting C<$PREFERRED_PARSER > variable in XML::Feed::RSS
362- package.
361+ change the class by setting C<$PREFERRED_PARSER > variable in the
362+ XML::Feed::Format::RSS package.
363363
364- $XML::Feed::RSS::PREFERRED_PARSER = "XML::RSS::LibXML";
364+ $XML::Feed::Format:: RSS::PREFERRED_PARSER = "XML::RSS::LibXML";
365365
366366B<Note: > this will only work for parsing feeds, not creating feeds.
367367
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ sub enclosure {
319319 return 1;
320320 } else {
321321 my @links = grep { defined $_ -> rel && $_ -> rel eq ' enclosure' } $entry -> {entry }-> link ;
322- return undef unless @links ;
322+ return unless @links ;
323323 my @encs = map { XML::Feed::Enclosure-> new({ url => $_ -> href, length => $_ -> length , type => $_ -> type }) } @links ;
324324 return ($XML::Feed::MULTIPLE_ENCLOSURES )? @encs : $encs [-1];
325325 }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ use base qw( XML::Feed );
77use DateTime::Format::Mail;
88use DateTime::Format::W3CDTF;
99use XML::Atom::Util qw( iso2dt) ;
10+ use XML::Feed::Enclosure;
1011
1112our $PREFERRED_PARSER = " XML::RSS" ;
1213
@@ -190,7 +191,9 @@ sub link {
190191 # # For RSS 2.0 output from XML::RSS. Sigh.
191192 $entry -> {entry }{permaLink } = $_ [0];
192193 } else {
193- $entry -> {entry }{link } || $entry -> {entry }{guid };
194+ $entry -> {entry }{link } ||
195+ $entry -> {entry }{permaLink } ||
196+ $entry -> {entry }{guid };
194197 }
195198}
196199
@@ -356,8 +359,12 @@ sub enclosure {
356359 }
357360 } else {
358361 my $tmp = $entry -> {entry }-> {enclosure };
359- my @encs = map { XML::Feed::Enclosure-> new($_ ) } (ref $tmp eq ' ARRAY' )? @$tmp : ($tmp );
360- return ($XML::Feed::MULTIPLE_ENCLOSURES )? @encs : $encs [-1];
362+ if (defined $tmp ) {
363+ my @encs = map { XML::Feed::Enclosure-> new($_ ) }
364+ (ref $tmp eq ' ARRAY' )? @$tmp : ($tmp );
365+ return ($XML::Feed::MULTIPLE_ENCLOSURES )? @encs : $encs [-1];
366+ }
367+ return ;
361368 }
362369}
363370
Original file line number Diff line number Diff line change 1+ use strict;
2+ use Test::More;
3+
4+ use XML::Feed;
5+
6+ my @formats = qw/ rss20 atom/ ;
7+
8+ plan tests => 2*@formats ;
9+
10+ for my $format (@formats ) {
11+ ok (my $feed = XML::Feed-> parse(" t/samples/$format .xml" ), " Parsed $format " );
12+ my ($entry ) = $feed -> entries;
13+ my @enclosure = $entry -> enclosure;
14+ is(@enclosure , 0);
15+ }
Original file line number Diff line number Diff line change 1+ use strict;
2+ use warnings;
3+
4+ use Test::More tests => 2;
5+ use XML::Feed;
6+
7+ my $file = ' t/samples/rss20-p.xml' ;
8+ my $feed = XML::Feed-> parse($file );
9+ isa_ok($feed , ' XML::Feed::Format::RSS' );
10+ my $entry = ($feed -> entries)[0];
11+ is($entry -> link , ' http://creograf.ru/post/regexp -js' );
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <rss version =" 2.0"
3+ xmlns : blogChannel =" http://backend.userland.com/blogChannelModule" >
4+ <channel >
5+ <title >Some title</title >
6+ <link >http://creograf.ru/blog/4progr ammer</link >
7+ <description >Some desc</description >
8+ <language >ru-ru</language >
9+ <pubDate >Sun, 3 Apr 2011 05:42:15 +0300</pubDate >
10+ <lastBuildDate >Sun, 3 Apr 2011 05:42:15 +0300</lastBuildDate >
11+
12+ <item >
13+ <title >Some entry</title >i
14+ <description ></description >
15+ <guid isPermaLink =" true" >http://creograf.ru/post/regexp -js</guid >
16+ <pubDate >Sun, 3 Apr 2011 05:42:12 +0300</pubDate >
17+ </item >
18+ </channel >
19+ </rss >
You can’t perform that action at this time.
0 commit comments