[Rt-commit] r11978 - in rt/branches/3.8-TESTING: .

alexmv at bestpractical.com alexmv at bestpractical.com
Wed Apr 30 14:49:19 EDT 2008


Author: alexmv
Date: Wed Apr 30 14:49:18 2008
New Revision: 11978

Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/lib/RT/Template_Overlay.pm

Log:
 r31069 at kohr-ah:  chmrr | 2008-04-30 14:48:57 -0400
  * Don't "upgrade" plaintext messages to have HTML versions


Modified: rt/branches/3.8-TESTING/lib/RT/Template_Overlay.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Template_Overlay.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Template_Overlay.pm	Wed Apr 30 14:49:18 2008
@@ -312,10 +312,7 @@
     my $orig_entity = $self->MIMEObj;
     my $mime_type   = $self->MIMEObj->mime_type;
 
-    if (!$mime_type or $mime_type eq 'text/plain') {
-        $self->_UpgradeToHTML(@_);
-    }
-    elsif ($mime_type eq 'text/html') {
+    if (defined $mime_type and $mime_type eq 'text/html') {
         $self->_DowngradeFromHTML(@_);
     }
 
@@ -476,70 +473,6 @@
     return ($rv, $msg);
 }
 
-sub _UpgradeToHTML {
-    my $self = shift;
-    my $orig_entity = $self->MIMEObj;
-
-    local $RT::Transaction::PreferredContentType = 'text/html';
-
-    require Text::Template;
-    my $old_compile = \&Text::Template::compile;
-    local *Text::Template::compile = sub {
-        $old_compile->(@_) or return undef;
-        
-        my $self = shift;
-        my @new_content;
-        my $in_body;
-        foreach my $chunk (@{$self->{SOURCE}}) {
-            if ($chunk->[0] eq 'TEXT') {
-                my $new_text = $chunk->[1];
-                my $prepend = '';
-                if (!$in_body) {
-                    # We don't HTMLify anything within the header.
-                    if ($new_text =~ /\n\r?\n/) {
-                        $in_body = 1;
-
-                        # Preserve the header text but upgrade the body text
-                        ($prepend, $new_text) = split(/(?<=\n\r\n)|(?<=\n\n)/, $new_text, 2);
-                    }
-                    else {
-                        push @new_content, $chunk;
-                        next;
-                    }
-                }
-                $new_text =~ s/&/&#38;/g;
-                $new_text =~ s/</&lt;/g;
-                $new_text =~ s/>/&gt;/g;
-                $new_text =~ s/\n/\n<br \/>/g;
-                push @new_content, [$chunk->[0], $prepend.$new_text, $chunk->[2]];
-            }
-            else {
-                push @new_content, $chunk;
-            }
-        }
-        $self->{SOURCE} = \@new_content;
-    };
-
-    my ($rv, $msg) = $self->_Parse(@_);
-    if (!$rv) {
-        $self->{MIMEObj} = $orig_entity;
-        return;
-    }
-
-    $orig_entity->head->mime_attr( "Content-Type" => 'text/plain' );
-    $orig_entity->head->mime_attr( "Content-Type.charset" => 'utf-8' );
-    $orig_entity->make_multipart('alternative', Force => 1);
-
-    my $new_entity = $self->{MIMEObj};
-    $new_entity->head->mime_attr( "Content-Type" => 'text/html' );
-    $new_entity->head->mime_attr( "Content-Type.charset" => 'utf-8' );
-
-    $orig_entity->add_part($new_entity);
-    $self->{MIMEObj} = $orig_entity;
-
-    return ($rv, $msg);
-}
-
 =head2 CurrentUserHasQueueRight
 
 Helper function to call the template's queue's CurrentUserHasQueueRight with the passed in args.


More information about the Rt-commit mailing list