Added new tests to prove what the problem is.
Dave Cross [Sun, 13 Mar 2011 10:20:11 +0000 (10:20 +0000)]
t/17-double.t [new file with mode: 0644]
t/18-double2.t [new file with mode: 0644]
t/samples/rss10-double.xml [new file with mode: 0644]
t/samples/rss20-double.xml [new file with mode: 0644]

diff --git a/t/17-double.t b/t/17-double.t
new file mode 100644 (file)
index 0000000..6bd4262
--- /dev/null
@@ -0,0 +1,21 @@
+use Test::More 'no_plan';
+
+use XML::Feed;
+
+my $rss = XML::Feed->parse('t/samples/rss10-double.xml');
+isa_ok($rss, 'XML::Feed::Format::RSS');
+my $rss_entry = ($rss->entries)[0];
+isa_ok($rss_entry, 'XML::Feed::Entry::Format::RSS');
+my $rss_content = $rss_entry->content;
+isa_ok($rss_content, 'XML::Feed::Content');
+is($rss_content->type, 'text/html', 'Correct content type');
+like($rss_content->body, qr(<|&lt;), 'Contains HTML tags');
+
+my $atom = $rss->convert('Atom');
+isa_ok($atom, 'XML::Feed::Format::Atom');
+my $atom_entry = ($atom->entries)[0];
+isa_ok($atom_entry, 'XML::Feed::Entry::Format::Atom');
+my $atom_content = $atom_entry->content;
+isa_ok($atom_content, 'XML::Feed::Content');
+is($atom_content->type, 'text/html', 'Correct content type');
+like($atom_content->body, qr(<|&lt;), 'Contains HTML tags');
diff --git a/t/18-double2.t b/t/18-double2.t
new file mode 100644 (file)
index 0000000..b992d82
--- /dev/null
@@ -0,0 +1,71 @@
+use strict;
+use warnings;
+
+use Test::More tests => 14;
+
+use XML::Feed;
+use File::Spec;
+
+
+{
+    my $rss = XML::Feed->parse(
+        File::Spec->catfile(File::Spec->curdir(), 
+            "t", "samples", "rss20-double.xml"
+        )
+    );
+
+    # TEST
+    isa_ok($rss, 'XML::Feed::Format::RSS');
+    my $rss_entry = ($rss->entries)[0];
+
+    # TEST
+    isa_ok($rss_entry, 'XML::Feed::Entry::Format::RSS');
+
+
+    my $rss_content = $rss_entry->content;
+
+    # TEST
+    isa_ok($rss_content, 'XML::Feed::Content');
+
+    # TEST
+    is($rss_content->type, 'text/html', 'Correct content type');
+
+    # TEST
+    like($rss_content->body, qr(<|&lt;), 'Contains HTML tags');
+
+    # TEST
+    like($rss_content->body, 
+         qr{\A\Q<div class='snap_preview'><br /><p style="text-align:justify;"><span style="color:#000000;">In an interesting, not to say quixotic},
+         'Contains HTML tags');
+
+    unlike($rss->as_xml, qr{&amp;lt;}, 'No double encoding');
+
+    my $atom = $rss->convert('Atom');
+
+    # TEST
+    isa_ok($atom, 'XML::Feed::Format::Atom');
+
+    my $atom_entry = ($atom->entries)[0];
+
+    # TEST
+    isa_ok($atom_entry, 'XML::Feed::Entry::Format::Atom');
+
+    my $atom_content = $atom_entry->content;
+
+    # TEST
+    isa_ok($atom_content, 'XML::Feed::Content');
+
+    # TEST
+    is($atom_content->type, 'text/html', 'Correct content type');
+
+    # TEST
+    like($atom_content->body, qr(<|&lt;), 'Contains HTML tags');
+
+    # TEST
+    like($atom_content->body, 
+        qr{\A\Q&lt;div class=&#39;snap_preview&#39;&gt;&lt;br /&gt;&lt;p style=&quot;text-align:justify;&quot;&gt;&lt;span style=&quot;color:#000000;&quot;&gt;In an interesting, not to say quixotic},
+        'Contains HTML tags');
+
+    unlike($atom->as_xml, qr{&amp;lt;}, 'No double encoding');
+}
+
diff --git a/t/samples/rss10-double.xml b/t/samples/rss10-double.xml
new file mode 100644 (file)
index 0000000..d4519b9
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<rdf:RDF
+xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+xmlns="http://purl.org/rss/1.0/"
+xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
+xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
+xmlns:dc="http://purl.org/dc/elements/1.1/"
+xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
+xmlns:admin="http://webns.net/mvcb/"
+>
+
+<channel rdf:about="http://use.perl.org/~davorg/journal/">
+<title>davorg's Journal</title>
+<link>http://use.perl.org/~davorg/journal/</link>
+<description>davorg's use Perl Journal</description>
+<dc:language>en-us</dc:language>
+<dc:rights>use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.</dc:rights>
+<dc:date>2009-04-09T12:53:36+00:00</dc:date>
+<dc:publisher>pudge</dc:publisher>
+<dc:creator>pudge@perl.org</dc:creator>
+<dc:subject>Technology</dc:subject>
+<syn:updatePeriod>hourly</syn:updatePeriod>
+<syn:updateFrequency>1</syn:updateFrequency>
+<syn:updateBase>1970-01-01T00:00+00:00</syn:updateBase>
+<items>
+<rdf:Seq>
+<rdf:li rdf:resource="http://use.perl.org/~davorg/journal/38730?from=rss" />
+</rdf:Seq>
+</items>
+<image rdf:resource="http://use.perl.org/images/topics/useperl.gif" />
+</channel>
+
+<image rdf:about="http://use.perl.org/images/topics/useperl.gif">
+<title>davorg's Journal</title>
+<url>http://use.perl.org/images/topics/useperl.gif</url>
+<link>http://use.perl.org/~davorg/journal/</link>
+</image>
+
+<item rdf:about="http://use.perl.org/~davorg/journal/38730?from=rss">
+<title>Task::Kensho RPMs</title>
+<link>http://use.perl.org/~davorg/journal/38730?from=rss</link>
+<description>&lt;p&gt;One of the first concrete outputs from the &lt;a href="http://www.enlightenedperl.org/"&gt;Enlightened Perl Organisation&lt;/a&gt; has been &lt;a href="http://search.cpan.org/dist/Task-Kensho/"&gt;Task::Kensho&lt;/a&gt; - a CPAN module which exists to list a number of other CPAN modules that modern Perl programmers should consider using. if you install Task::Kensho then all of the included modules will automatically be pulled down from CPAN and installed.&lt;/p&gt;&lt;p&gt;I don't install my modules from CPAN. As I live in the Red Hat world, I like to install RPMs of modules. And I build RPMs for modules that aren't already available in that format (and then I &lt;a href="http://rpm.mag-sol.com/"&gt;make them available to everyone&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;So last night I created an RPM for Task::Kensho. This also involved building RPMs for about half of the modules it include which didn't already exist as RPMs in the standard repostories. Those RPMs are now available from &lt;a href="http://rpm.mag-sol.com/"&gt;my repository&lt;/a&gt; so installing them all could be as simple as &lt;tt&gt;sudo yum install perl-Task-Kensho&lt;/tt&gt;. Of course, you can also install individual packages using the appropriate &lt;tt&gt;yum&lt;/tt&gt; command.&lt;/p&gt;&lt;p&gt;Currently the RPMs are only available for Fedora 10. I'll build versions for Centos 5 over the next couple of days.&lt;/p&gt;</description>
+<dc:creator>davorg</dc:creator>
+<dc:date>2009-03-31T08:02:06+00:00</dc:date>
+<dc:subject>journal</dc:subject>
+</item>
+</rdf:RDF>
diff --git a/t/samples/rss20-double.xml b/t/samples/rss20-double.xml
new file mode 100644 (file)
index 0000000..37bc1c5
--- /dev/null
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
+
+<channel>
+<title>David Jones, MP</title>
+
+<link>http://davidjonesblog.com</link>
+<description>Conservative Member of Parliament for Clwyd West; Shadow Minister for Wales</description>
+<lastBuildDate>Sat, 10 Oct 2009 14:44:32 +0000</lastBuildDate>
+<generator>http://wordpress.com/</generator>
+<language>en</language>
+<sy:updatePeriod>hourly</sy:updatePeriod>
+<sy:updateFrequency>1</sy:updateFrequency>
+<cloud domain="davidjonesblog.com" port="80" path="/?rsscloud=notify" registerProcedure="" protocol="http-post" />
+<image>
+<url>http://www.gravatar.com/blavatar/a828c934fa71b769302493ee214f134d?s=96&amp;d=http://s.wordpress.com/i/buttonw-com.png</url>
+<title>David Jones, MP</title>
+<link>http://davidjonesblog.com</link>
+</image>
+<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/wordpress/GWIK" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
+<title>Sunny Gordon</title>
+<link>http://feedproxy.google.com/~r/wordpress/GWIK/~3/YVku-jKELKs/</link>
+<comments>http://davidjonesblog.com/2009/10/10/sunny-gordon/#comments</comments>
+<pubDate>Sat, 10 Oct 2009 11:57:47 +0000</pubDate>
+<dc:creator>David Jones</dc:creator>
+<category><![CDATA[Conservative Party]]></category>
+<category><![CDATA[Gordon Brown]]></category>
+<category><![CDATA[Labour Party]]></category>
+<category><![CDATA[economy]]></category>
+<category><![CDATA[Politics]]></category>
+
+<guid isPermaLink="false">http://davidjonesblog.com/?p=4022</guid>
+<description><![CDATA[With Gordon at the helm, Labour are going to let the good times roll.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidjonesblog.com&blog=5996455&post=4022&subd=davidjonesmp&ref=&feed=1" />]]></description>
+<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:justify;"><span style="color:#000000;">In an interesting, not to say quixotic, attempt at repositioning, Gordon Brown, in an interview Â in the <em><a href="http://www.telegraph.co.uk/news/newstopics/politics/gordon-brown/6286070/Britains-economy-ready-to-bounce-back-says-Gordon-Brown.html">Telegraph</a></em> this morning, seeks to portray himself as a sunny optimist, in contrast to the doom-and-gloom mongers of the Conservative party.</span></p>
+<p style="text-align:justify;"><span style="color:#000000;">It is â\80\9csimply not trueâ\80\9d, says Mr Brown, that tough economic times lie ahead.  No, says the PM, his drive for economic growth will pull the country out of recession; with Gordon at the helm, Labour are going to let the good times roll.</span></p>
+<p style="text-align:justify;"><span style="color:#000000;">Gratifying as it is to see this hitherto unsuspected Louis Armstrong side to the Prime Ministerâ\80\99s personality, it is unlikely that his new line will cut much ice with an informed electorate.  The Treasuryâ\80\99s own figures indicate that:</span></p>
+<ul style="text-align:justify;">
+<li><span style="color:#000000;">the social security bill will mount to almost Â£200 billion in four yearsâ\80\99 time â\80\93 almost twice the NHS budget;</span></li>
+<li><span style="color:#000000;">debt interest will rise to Â£63 billion per annum;</span></li>
+<li><span style="color:#000000;">the total cost of welfare and debt maintenance will amount to one-third of government expenditure.</span></li>
+</ul>
+<p style="text-align:justify;"><span style="color:#000000;">In the circumstances, itâ\80\99s rather hard to see that the Tories are being anything other than totally realistic when they warn of hard years to come.   Giving a cheery whistle, as Gordon appears to be advising, isnâ\80\99t really going to help an awful lot.</span></p>
+Posted in Conservative Party, economy, Gordon Brown, Labour Party Tagged: Politics <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/davidjonesmp.wordpress.com/4022/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/davidjonesmp.wordpress.com/4022/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/davidjonesmp.wordpress.com/4022/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/davidjonesmp.wordpress.com/4022/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/davidjonesmp.wordpress.com/4022/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/davidjonesmp.wordpress.com/4022/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/davidjonesmp.wordpress.com/4022/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/davidjonesmp.wordpress.com/4022/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/davidjonesmp.wordpress.com/4022/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/davidjonesmp.wordpress.com/4022/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=davidjonesblog.com&blog=5996455&post=4022&subd=davidjonesmp&ref=&feed=1" /></div>]]></content:encoded>
+<wfw:commentRss>http://davidjonesblog.com/2009/10/10/sunny-gordon/feed/</wfw:commentRss>
+<slash:comments>1</slash:comments>
+
+<media:content url="http://0.gravatar.com/avatar/aea1b4a642b604d87d34047223aab73b?s=96&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" medium="image">
+<media:title type="html">David Jones MP</media:title>
+</media:content>
+<feedburner:origLink>http://davidjonesblog.com/2009/10/10/sunny-gordon/</feedburner:origLink></item>
+</channel>
+</rss>