Subject: | <guid> element outside of <item> causes fatal error |
Date: | Fri, 23 Oct 2009 16:31:23 -0400 (EDT) |
To: | bug-XML-RSS [...] rt.cpan.org |
From: | Matt Riffle <matt [...] pair.com> |
XML::RSS Version: 1.46
A <guid> element that is outside of an <item> element (which is invalid
RSS, admittedly) causes this fatal error:
Modification of non-creatable array value attempted, subscript -1 at
/usr/local/lib/perl5/site_perl/5.8.9/XML/RSS.pm line 914, <DATA> line 42.
That's a call to _last_item, which seems to happen at line 1019:
elsif ($el eq 'guid') {
$self->_last_item->{'isPermaLink'} =
(exists($attribs{'isPermaLink'}) &&
(lc($attribs{'isPermaLink'}) eq 'true')
);
Below is a patch that seems to solve the issue, though I confess I'm not
familiar enough with the overall codebase to know if it has other
side-effects. It also assumes you want to accept the input, rather than,
say, throwing a more informative error.
Thanks,
Matt Riffle
pair Networks, Inc.
--
914c914,916
< return ($self->{'items'}->[$self->{num_items} - 1] ||= {});
---
Show quoted text
> #return ($self->{'items'}->[$self->{num_items} - 1] ||= {});
> return (ref($self->{'items'}) eq 'ARRAY') ?
> $self->{'items'}->[$self->{num_items} - 1] : {};
1020c1022
< $self->_last_item->{'isPermaLink'} =
---
Show quoted text> $self->_last_item and $self->_last_item->{'isPermaLink'} =