Skip Menu |

This queue is for tickets about the XML-RSS CPAN distribution.

Report information
The Basics
Id: 25336
Status: resolved
Priority: 0/
Queue: XML-RSS

People
Owner: Nobody in particular
Requestors: jmrodri [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: namespaces with attributes not rendered correctly.
Date: Thu, 8 Mar 2007 10:32:40 -0500
To: bug-XML-RSS [...] rt.cpan.org
From: "Jesus M. Rodriguez" <jmrodri [...] gmail.com>
Dist name & version: XML-RSS 1.22 Perl version: perl-5.8.8-2.el4s1 OS: Red Hat Enterprise Linux 4 uname -a: Linux corvette.home.net 2.6.9-42.0.3.EL #1 Mon Sep 25 17:14:19 EDT 2006 i686 i686 i386 GNU/Linux Adding a namespace that has attributes doesn't render correctly. my $s2frss = new XML::RSS; $s2frss->add_module(prefix=>'media', uri=>'http://search.yahoo.com/mrss/'); $s2frss->add_item(... media => { title => $item->{'title'}, text => $item->{'description'}, content => { url => $item->{'enclosure'}->{'url'}, type => "image/jpeg", height => "100", # change later width => "100" }, ... print $s2frss->as_string; This renders as follows: <media:content>HASH(0x9abc8ad)</media:content> Expected result: <media:content url="http://...." type="image/jpeg" height="100" width="100"/> I have attached a test script used to recreate the problem, and a patch to RSS.pm.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

From: joules [...] gorfajn.com
The attached patch does not operate correctly. Caues "<media:>" and I think we want to unconditionally quote the attributes instead of using _encode(). Attached is my modificaiton. On Thu Mar 08 10:33:14 2007, jmrodri@gmail.com wrote: Show quoted text
> Dist name & version: XML-RSS 1.22 > Perl version: perl-5.8.8-2.el4s1 > OS: Red Hat Enterprise Linux 4 > uname -a: Linux corvette.home.net 2.6.9-42.0.3.EL #1 Mon Sep 25 > 17:14:19 EDT 2006 i686 i686 i386 GNU/Linux > > Adding a namespace that has attributes doesn't render correctly. > > > my $s2frss = new XML::RSS; > $s2frss->add_module(prefix=>'media', > uri=>'http://search.yahoo.com/mrss/'); > $s2frss->add_item(... > media => { > title => $item->{'title'}, > text => $item->{'description'}, > content => { > url => $item->{'enclosure'}->{'url'}, > type => "image/jpeg", > height => "100", # change later > width => "100" > }, > ... > print $s2frss->as_string; > > This renders as follows: > > <media:content>HASH(0x9abc8ad)</media:content> > > Expected result: > > <media:content url="http://...." type="image/jpeg" height="100" > width="100"/> > > I have attached a test script used to recreate the problem, and a > patch to RSS.pm.
--- RSS.pm 2006-12-17 10:38:27.000000000 -0500 +++ /usr/lib/perl5/vendor_perl/5.8.8/XML/RSS.pm 2007-06-20 14:03:51.000000000 -0400 @@ -1576,7 +1576,15 @@ $self->_encode($value) . "\" />\n"; } - else { + elsif ( ref($value) eq 'HASH') { + # get keys, for each key: print key=value + $output .= "<$prefix:$el"; + while ( my ($key, $val) = each(%$value) ) { + $output .= " ". $key . "=\"". $val . "\"\n"; + } + $output .= "/>\n"; + } + elsif ($el) { $output .= "<$prefix:$el>". $self->_encode($value) ."</$prefix:$el>\n"; } }
This is resolved in the svn trunk. A few notes: 1. One should always use _encode for data that is received from the user. So the patch by joules could not be accepted. 2. Next time try to patch the svn trunk: https://svn.perl.org/modules/XML-RSS/trunk/ Regards, Shlomi Fish