[Rt-commit] r19641 - in rt/3.8/trunk: . lib/RT/Interface share/html/Ticket/Attachment/WithHeaders

falcone at bestpractical.com falcone at bestpractical.com
Tue May 12 18:05:31 EDT 2009


Author: falcone
Date: Tue May 12 18:05:27 2009
New Revision: 19641

Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/lib/RT/Attachment_Overlay.pm   (contents, props changed)
   rt/3.8/trunk/lib/RT/Interface/Email.pm
   rt/3.8/trunk/share/html/Ticket/Attachment/WithHeaders/dhandler

Log:
 r47511 at ketch:  falcone | 2009-05-12 18:03:47 -0400
 * revert 19580, 19579, 19578, 19576, 19552 and move to a branch
   (we aren't shipping these in 3.8.3 and there is some debate about
    tests and the right solutions)


Modified: rt/3.8/trunk/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Attachment_Overlay.pm	(original)
+++ rt/3.8/trunk/lib/RT/Attachment_Overlay.pm	Tue May 12 18:05:27 2009
@@ -320,46 +320,6 @@
     return $content;
 }
 
-=head2 OriginalHeaders
-
-Returns the attachment's headers as octets before RT's mangling.  Currently,
-this just means restoring text headers back to their original encoding.
-
-=cut
-
-sub OriginalHeaders {
-    my $self = shift;
-
-    return $self->Headers unless RT::I18N::IsTextualContentType($self->ContentType);
-    my $enc = $self->OriginalEncoding;
-
-    my $headers;
-    if ( !$self->ContentEncoding || $self->ContentEncoding eq 'none' ) {
-        $headers = $self->_Value('Headers', decode_utf8 => 0);
-    } elsif ( $self->ContentEncoding eq 'base64' ) {
-        $headers = MIME::Base64::decode_base64($self->_Value('Headers', decode_utf8 => 0));
-    } elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
-        $headers = MIME::QuotedPrint::decode($self->_Value('Headers', decode_utf8 => 0));
-    } else {
-        return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
-    }
-
-    # Turn *off* the SvUTF8 bits here so decode_utf8 and from_to below can work.
-    local $@;
-    Encode::_utf8_off($headers);
-
-    if (!$enc || $enc eq '' ||  $enc eq 'utf8' || $enc eq 'utf-8') {
-        # If we somehow fail to do the decode, at least push out the raw bits
-        eval { return( Encode::decode_utf8($headers)) } || return ($headers);
-    }
-
-    eval { Encode::from_to($headers, 'utf8' => $enc) } if $enc;
-    if ($@) {
-        $RT::Logger->error("Could not convert attachment headers from assumed utf8 to '$enc' :".$@);
-    }
-    return $headers;
-}
-
 =head2 OriginalEncoding
 
 Returns the attachment's original encoding.
@@ -457,12 +417,8 @@
     my $self = shift;
 
     my $entity = new MIME::Entity;
-    foreach my $header ($self->SplitHeaders) {
-        my ($h_key, $h_val) = split /:/, $header, 2;
-	# We need to encode header as RFC 2047, to avoid conflict with
-	# OrignalContent Encoding that may break display
-        $entity->head->add( $h_key, Encode::encode('MIME-Header', $h_val ) );
-    }
+    $entity->head->add( split /:/, $_, 2 )
+        foreach $self->SplitHeaders;
 
     use MIME::Body;
     $entity->bodyhandle(

Modified: rt/3.8/trunk/lib/RT/Interface/Email.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Interface/Email.pm	(original)
+++ rt/3.8/trunk/lib/RT/Interface/Email.pm	Tue May 12 18:05:27 2009
@@ -622,7 +622,7 @@
         );
     }
 
-    $mail->head->set( $_ => Encode::encode('MIME-Header', $args{ $_ }) )
+    $mail->head->set( $_ => $args{ $_ } )
         foreach grep defined $args{$_}, qw(To Cc Bcc);
 
     $mail->attach(
@@ -643,8 +643,8 @@
         $from = $obj->QueueObj->CorrespondAddress
             || RT->Config->Get('CorrespondAddress');
     }
-    $mail->head->set( Subject => Encode::encode('MIME-Header', "Fwd: $subject") );
-    $mail->head->set( From    => Encode::encode('MIME-Header', $from) );
+    $mail->head->set( Subject => "Fwd: $subject" );
+    $mail->head->set( From    => $from );
 
     my $status = RT->Config->Get('ForwardFromUser')
         # never sign if we forward from User

Modified: rt/3.8/trunk/share/html/Ticket/Attachment/WithHeaders/dhandler
==============================================================================
--- rt/3.8/trunk/share/html/Ticket/Attachment/WithHeaders/dhandler	(original)
+++ rt/3.8/trunk/share/html/Ticket/Attachment/WithHeaders/dhandler	Tue May 12 18:05:27 2009
@@ -59,18 +59,10 @@
         Abort("Couldn't load attachment #$id");
     }
 
-    my $content_type = 'text/plain';
-    if ( my $enc = $AttachmentObj->OriginalEncoding ) {
-        # normalize Encode.pm convention with IANA ones
-        $enc = 'big5'  if $enc eq 'big5-eten';
-        $enc = 'utf-8' if $enc eq 'utf8';
-        $content_type .= ";charset=$enc";
-    }
-
     # XXX: should we check handle html here and integrate headers into html?
-    $r->content_type( $content_type );
+    $r->content_type( 'text/plain' );
     $m->clear_buffer;
-    $m->out( $AttachmentObj->OriginalHeaders );
+    $m->out( $AttachmentObj->Headers );
     $m->out( "\n\n" );
     $m->out( $AttachmentObj->OriginalContent );
     $m->abort;


More information about the Rt-commit mailing list