From: Simon Wistow Date: Mon, 22 Mar 2010 20:50:41 +0000 (+0000) Subject: Fix double encoding bug? X-Git-Tag: RELEASE_0.45~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FXML-Feed.git;a=commitdiff_plain;h=b7c406f5741bfbfff25226734d99c28c6f776661 Fix double encoding bug? --- diff --git a/MANIFEST b/MANIFEST index 8ad6cbc..f963f13 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,13 +1,13 @@ Build.PL Changes -lib/XML/Feed.pm lib/XML/Feed/Content.pm lib/XML/Feed/Enclosure.pm lib/XML/Feed/Entry.pm lib/XML/Feed/Format/Atom.pm lib/XML/Feed/Format/RSS.pm -MANIFEST This list of files +lib/XML/Feed.pm MANIFEST.SKIP +MANIFEST This list of files META.yml README t/00-compile.t @@ -24,13 +24,14 @@ t/10-mix-and-match.t t/11-xml-base-atom.t t/11-xml-base-rss.t t/12-multi-categories-atom.t -t/12-multi-categories-rss.t t/12-multi-categories.base +t/12-multi-categories-rss.t t/12-multi-subjects-rss.t t/13-category-hash-bug.t t/14-enclosures.t t/14-multi-enclosures.t t/15-odd-date.t +t/16-convert.t t/pod-coverage.t t/pod.t t/samples/atom-10-example.xml @@ -42,8 +43,7 @@ t/samples/atom.xml t/samples/base_atom.xml t/samples/base_rss.xml t/samples/category-bug.xml -t/samples/rss-multiple-categories.xml -t/samples/rss-multiple-subjects.xml +t/samples/rss10-davorg-journal.xml t/samples/rss10-invalid-date.xml t/samples/rss10-odd-date.xml t/samples/rss10.xml @@ -51,3 +51,5 @@ t/samples/rss20-enclosure.xml t/samples/rss20-multi-enclosure.xml t/samples/rss20-no-summary.xml t/samples/rss20.xml +t/samples/rss-multiple-categories.xml +t/samples/rss-multiple-subjects.xml diff --git a/lib/XML/Feed/Format/Atom.pm b/lib/XML/Feed/Format/Atom.pm index 90987d5..7e8feba 100644 --- a/lib/XML/Feed/Format/Atom.pm +++ b/lib/XML/Feed/Format/Atom.pm @@ -8,6 +8,7 @@ use XML::Atom::Feed; use XML::Atom::Util qw( iso2dt ); use List::Util qw( first ); use DateTime::Format::W3CDTF; +use HTML::Entities; use XML::Atom::Entry; XML::Atom::Entry->mk_elem_accessors(qw( lat long ), ['http://www.w3.org/2003/01/geo/wgs84_pos#']); @@ -196,17 +197,31 @@ sub content { if (@_) { my %param; my $base; + my $orig_body; if (ref($_[0]) eq 'XML::Feed::Content') { + $orig_body = $_[0]->body; if (defined $_[0]->type && defined $types{$_[0]->type}) { %param = (Body => $_[0]->body, Type => $types{$_[0]->type}); + + if ($param{'Type'} eq "html") { + $param{'Body'} = HTML::Entities::encode_entities($param{'Body'}); + } } else { - %param = (Body => $_[0]->body); + %param = (Body => $_[0]->body); } $base = $_[0]->base if defined $_[0]->base; } else { + $orig_body = $_[0]; %param = (Body => $_[0]); } + #if (!exists($param{Body})) + #{ + # $param{Body} = $orig_body; + #} $entry->{entry}->content(XML::Atom::Content->new(%param, Version => 1.0)); + # Assigning again so the type will be normalized. This seems to be + # an XML-Atom do-what-I-don't-meannery. + #$entry->{entry}->content->body($orig_body); $entry->{entry}->content->base($base) if defined $base; } else { my $c = $entry->{entry}->content;