[Rt-commit] r9640 - rt/branches/3.6-RELEASE/lib/RT/Action

audreyt at bestpractical.com audreyt at bestpractical.com
Sun Nov 11 14:07:44 EST 2007


Author: audreyt
Date: Sun Nov 11 14:07:43 2007
New Revision: 9640

Modified:
   rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm

Log:
* RT::Action::SendEmail: Allow user-specified Content-Type
  in outgoing templates.  Currently, only text/* is supported
  for security reasons.  Eventually maybe multipart/* with
  all textual subparts might be allowed, too.

Modified: rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm	(original)
+++ rt/branches/3.6-RELEASE/lib/RT/Action/SendEmail.pm	Sun Nov 11 14:07:43 2007
@@ -164,16 +164,20 @@
     # We should never have to set the MIME-Version header
     $self->SetHeader( 'MIME-Version', '1.0' );
 
+    # For security reasons, we only send out text/* mails.
+    my $content_type = $MIMEObj->mime_type;
+    $content_type =~ s/;.*//;
+    $content_type = 'text/plain' unless ( $content_type =~ m{^text/} );
+
     # try to convert message body from utf-8 to $RT::EmailOutputEncoding
-    $self->SetHeader( 'Content-Type', 'text/plain; charset="utf-8"' );
+    $self->SetHeader( 'Content-Type', $content_type.'; charset="utf-8"' );
 
     # fsck.com #5959: Since RT sends 8bit mail, we should say so.
     $self->SetHeader( 'Content-Transfer-Encoding','8bit');
 
-
     RT::I18N::SetMIMEEntityToEncoding( $MIMEObj, $RT::EmailOutputEncoding,
         'mime_words_ok' );
-    $self->SetHeader( 'Content-Type', 'text/plain; charset="' . $RT::EmailOutputEncoding . '"' );
+    $self->SetHeader( 'Content-Type', $content_type.'; charset="' . $RT::EmailOutputEncoding . '"' );
 
     # Build up a MIME::Entity that looks like the original message.
     $self->AddAttachments() if ( $MIMEObj->head->get('RT-Attach-Message') );


More information about the Rt-commit mailing list