[Rt-commit] rt branch, 4.0/multipart-message-display, updated. rt-4.0.6-236-g07d34f6

Alex Vandiver alexmv at bestpractical.com
Mon Jul 2 18:36:36 EDT 2012


The branch, 4.0/multipart-message-display has been updated
       via  07d34f6012ab39774c39f8db1b2817db33ff8151 (commit)
       via  e6baebd1196a664034afa6559294d5882f915c34 (commit)
      from  cce49da4f121218b2c287821d7903299a311430c (commit)

Summary of changes:
 share/html/Ticket/Elements/ShowTransactionAttachments |   16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

- Log -----------------------------------------------------------------
commit e6baebd1196a664034afa6559294d5882f915c34
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jul 2 16:43:42 2012 -0400

    Factor out case-insensitive content-type header checks into a variable

diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index eb56f5c..b035778 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -144,6 +144,8 @@ my $render_attachment = sub {
     my $message = shift;
     my $name = defined $message->Filename && length $message->Filename ?  $message->Filename : '';
 
+    my $content_type = lc $message->ContentType;
+
     # if it has a content-disposition: attachment, don't show inline
     my $disposition = $message->GetHeader('Content-Disposition');
 
@@ -154,7 +156,7 @@ my $render_attachment = sub {
     }
 
     # If it's text
-    if ( $message->ContentType =~ m{^(text|message)}i ) {
+    if ( $content_type =~ m{^(text|message)/} ) {
         my $max_size = RT->Config->Get( 'MaxInlineBody', $session{'CurrentUser'} );
         if ( $disposition ne 'inline' ) {
             $m->out('<p>'. loc( 'Message body is not shown because sender requested not to inline it.' ) .'</p>');
@@ -181,10 +183,10 @@ my $render_attachment = sub {
             || (
                 (
                     RT->Config->Get('PreferRichText')
-                    && ( $message->ContentType =~ m{^text/(?:html|enriched)$}i )
+                    && ( $content_type =~ m{^text/(?:html|enriched)$} )
                 )
                 || ( !RT->Config->Get('PreferRichText')
-                    && ( $message->ContentType !~ m{^text/(?:html|enriched)$}i )
+                    && ( $content_type !~ m{^text/(?:html|enriched)$} )
                 )
             )
         ) {
@@ -198,7 +200,6 @@ my $render_attachment = sub {
                 $content = $message->Content;
             }
 
-            my $content_type = lc $message->ContentType;
             $RT::Logger->debug(
                 "Rendering attachment #". $message->id
                 ." of '$content_type' type"
@@ -232,7 +233,7 @@ my $render_attachment = sub {
             }
 
             # if it's a text/plain show the body
-            elsif ( $message->ContentType =~ m{^(text|message)}i ) {
+            elsif ( $content_type =~ m{^(text|message)/} ) {
 
                 unless ( length $name ) {
                     eval { require Text::Quoted;  $content = Text::Quoted::extract($content); };
@@ -250,7 +251,7 @@ my $render_attachment = sub {
     }
 
     # if it's an image, show it as an image
-    elsif ( RT->Config->Get('ShowTransactionImages') and  $message->ContentType =~ /^image\//i ) {
+    elsif ( RT->Config->Get('ShowTransactionImages') and  $content_type =~ m{^image/} ) {
         if ( $disposition ne 'inline' ) {
             $m->out('<p>'. loc( 'Message body is not shown because sender requested not to inline it.' ) .'</p>');
             return;

commit 07d34f6012ab39774c39f8db1b2817db33ff8151
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Mon Jul 2 16:54:34 2012 -0400

    This if() statement is guaranteed-true by the surrounding one

diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index b035778..95a2341 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -232,9 +232,8 @@ my $render_attachment = sub {
                 $m->out( $content );
             }
 
-            # if it's a text/plain show the body
-            elsif ( $content_type =~ m{^(text|message)/} ) {
-
+            # It's a text type we don't have special handling for
+            else {
                 unless ( length $name ) {
                     eval { require Text::Quoted;  $content = Text::Quoted::extract($content); };
                     if ($@) { $RT::Logger->warning( "Text::Quoted failed: $@" ) }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list