Subject: | Can't ->parsefile; the .rss from http://www.t3.co.uk/rss/ |
XML-RSS-1.04, perl 5.6.1, FreeBSD 4.10
Using rss.pl as follows <<__END__;
use XML::RSS;
my $rss = new XML::RSS;
$rss->parsefile("<downloaded .rss from http://www.t3.co.uk/rss/>");
__END__
Running this gives the error:
Use of uninitialized value in string eq at /home/y/lib/perl5/site_perl/5.6.1/XML/RSS.pm line 1483.
Use of uninitialized value in string eq at /home/y/lib/perl5/site_perl/5.6.1/XML/RSS.pm line 1348.
Modification of non-creatable array value attempted, subscript -1 at /home/y/lib/perl5/site_perl/5.6.1/XML/RSS.pm line 1355.
I've attached a patch that I created for RSS.pm that lets it parse the rss from t3.co.uk without a hitch. The problem seems to be '(!$ns && !$self->{rss_namespace})'. I made it just '!$ns' in all situations because I don't understand why we would expect $self->{rss_namespace} not to be defined. If someone is using rss as their default namespace, then that element _will_ be defined as per line 1456, but we might be inside an 'item' without a namespace since xmlns= might be set to rss.
Hmm... maybe it's meant to read (!$ns && $self->{rss_namespace}) ?? I guess ideally you want to set $self->{default_namespace} then you could do (!$ns && $self->{default_namespace} eq 'rss') or something along those lines. Maybe the intention was to cater for not having rss defined by some lazy rss generator, in which case the following clause might work:
!$self->{default_namespace} || (!$ns && $self->{default_namespace} eq 'rss') || ...
Would much appreciate it if I could find out when the package has either been updated with the patch, or with a more appropriate fix.
Cheers!
--- RSS.pm Wed Aug 11 16:41:07 2004
+++ /home/y/lib/perl5/site_perl/5.6.1/XML/RSS.pm Wed Aug 11 16:56:14 2004
@@ -1320,7 +1320,7 @@
my $ns = $self->namespace($self->current_element);
# If it's in the default namespace
if (
- (!$ns && !$self->{rss_namespace}) ||
+ !$ns ||
($ns eq $self->{rss_namespace})
) {
$self->{'image'}->{$self->current_element} .= $cdata;
@@ -1346,7 +1346,7 @@
# If it's in the default RSS 1.0 namespace
if (
- (!$ns && !$self->{rss_namespace}) ||
+ !$ns ||
($ns eq $self->{rss_namespace})
) {
$self->{'items'}->[$self->{num_items}-1]->{$self->current_element} .= $cdata;
@@ -1368,7 +1368,7 @@
# If it's in the default namespace
if (
- (!$ns && !$self->{rss_namespace}) ||
+ !$ns ||
($ns eq $self->{rss_namespace})
) {
$self->{'textinput'}->{$self->current_element} .= $cdata;
@@ -1406,7 +1406,7 @@
# If it's in the default namespace
if (
- (!$ns && !$self->{rss_namespace}) ||
+ !$ns ||
($ns eq $self->{rss_namespace})
) {
$self->{'channel'}->{$self->current_element} .= $cdata;
@@ -1481,7 +1481,7 @@
my $ns = $self->namespace( $el );
if (
- (!$ns && !$self->{rss_namespace}) ||
+ !$ns ||
($ns eq $self->{rss_namespace})
) {
# increment item count