rev 1936 - trunk/Email-Store-HTML/lib/Email/Store

[prev] [thread] [next] [lurker] [Date index for 2005/02/22]

From: simon
Subject: rev 1936 - trunk/Email-Store-HTML/lib/Email/Store
Date: 08:01 on 22 Feb 2005
Author: simon
Date: 2005-02-22 08:01:15 +0000 (Tue, 22 Feb 2005)
New Revision: 1936

Modified:
   trunk/Email-Store-HTML/lib/Email/Store/HTML.pm
Log:
Various fixes to get inline HTML working


Modified: trunk/Email-Store-HTML/lib/Email/Store/HTML.pm
===================================================================
--- trunk/Email-Store-HTML/lib/Email/Store/HTML.pm	2005-02-22 00:36:49 UTC (rev 1935)
+++ trunk/Email-Store-HTML/lib/Email/Store/HTML.pm	2005-02-22 08:01:15 UTC (rev 1936)
@@ -14,7 +14,7 @@
 use HTML::FormatText::WithLinks;        
 use vars qw($VERSION @allow @rules @default);
 
-$VERSION = "0.1";
+$VERSION = "0.3";
 
 
 sub on_store_order { 2 }
@@ -49,6 +49,27 @@
         my $text     =  $f->parse($raw); 
         Email::Store::HTML->create( { mail => $mail->id, raw => $raw, scrubbed => $scrubbed, as_text => $text } );
     }
+
+
+    my $ct = $mail->simple->header('Content-Type') || "";
+    if ($ct =~ m!text/html!i) {
+        my $raw      =  $mail->utf8_body;
+        my $scrubbed =  $scrubber->scrub($raw);
+        my $text     =  $f->parse($raw);
+        Email::Store::HTML->create( { mail => $mail->id, raw => $raw, scrubbed => $scrubbed, as_text => $text } );
+    }
+    
+    return unless ($ct =~ m!text/html!i || $mail->utf8_body =~ /^\s*$/s);
+
+    my @htmls = $mail->html; return unless @htmls;
+
+    my $simple = $mail->simple;
+    $simple->body_set($htmls[0]->as_text);
+    $mail->message($simple->as_string);
+    undef $mail->{simple}; # Invalidate cache
+    $mail->update;
+
+
 }
 
 =head1 NAME
@@ -132,7 +153,7 @@
 # Configuration for HTML::Scrubber
 ###
 
-my @allow = qw[ br hr b a p pre ul ol li i em strong table tr td th div ];
+my @allow = qw[ br hr b a p pre ul ol li i em strong table tr td th div span blockquote img sup sub ];
                                                                             #
 my @rules = (
         script => 0,

Generated at 09:00 on 22 Feb 2005 by mariachi 0.52