[Bast-commits] r6450 - in ironman/plagger/lib: Plagger/Plugin/Publish XML/Atom

szbalint at dev.catalyst.perl.org szbalint at dev.catalyst.perl.org
Thu May 28 16:06:31 GMT 2009


Author: szbalint
Date: 2009-05-28 16:06:31 +0000 (Thu, 28 May 2009)
New Revision: 6450

Modified:
   ironman/plagger/lib/Plagger/Plugin/Publish/Feed.pm
   ironman/plagger/lib/XML/Atom/Content.pm
Log:
Modifying XML::Atom::Content to fall back on our supplied type if body isn't valid xml.


Modified: ironman/plagger/lib/Plagger/Plugin/Publish/Feed.pm
===================================================================
--- ironman/plagger/lib/Plagger/Plugin/Publish/Feed.pm	2009-05-28 15:55:57 UTC (rev 6449)
+++ ironman/plagger/lib/Plagger/Plugin/Publish/Feed.pm	2009-05-28 16:06:31 UTC (rev 6450)
@@ -73,7 +73,7 @@
             if ($feed_format eq 'RSS') {
                 $entry->content($e->body);
             } else {
-                $entry->{entry}->content(XML::Atom::Content->new(Body => $e->body->utf8, Version => 1.0, Type => $e->body->type));
+                $entry->{entry}->content(XML::Atom::Content->new(Body => $e->body->utf8, Version => 1.0, AssumeType => $e->body->type));
             }
         }
 

Modified: ironman/plagger/lib/XML/Atom/Content.pm
===================================================================
--- ironman/plagger/lib/XML/Atom/Content.pm	2009-05-28 15:55:57 UTC (rev 6449)
+++ ironman/plagger/lib/XML/Atom/Content.pm	2009-05-28 16:06:31 UTC (rev 6450)
@@ -18,7 +18,7 @@
     my %param = @_ == 1 ? (Body => $_[0]) : @_;
     $content->SUPER::init(%param);
     if ($param{Body}) {
-        $content->body($param{Body});
+        $content->body($param{Body}, $param{AssumeType});
     }
     if ($param{Type}) {
         $content->type($param{Type});
@@ -31,6 +31,7 @@
     my $elem = $content->elem;
     if (@_) {
         my $data = shift;
+        my $assume_type = shift;
         if (LIBXML) {
             $elem->removeChildNodes;
         } else {
@@ -70,6 +71,7 @@
                 } else {
                     $content->type('xhtml');
                 }
+            # Content body is not valid xml, adding child node as text and if type assumption available, using that.
             } else {
                 if (LIBXML) {
                     $elem->appendChild(XML::LibXML::Text->new($data));
@@ -80,7 +82,11 @@
                 if ($content->version == 0.3) {
                     $content->mode('escaped');
                 } else {
-                    $content->type($data =~ /^\s*</ ? 'html' : 'text');
+                    if ($assume_type) {
+                      $content->type($assume_type);
+                    } else {
+                      $content->type($data =~ /^\s*</ ? 'html' : 'text');
+                    }
                 }
             }
         }




More information about the Bast-commits mailing list