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

audreyt at bestpractical.com audreyt at bestpractical.com
Mon Nov 12 03:02:36 EST 2007


Author: audreyt
Date: Mon Nov 12 03:02:35 2007
New Revision: 9646

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

Log:
* RT::Attachment_Overlay - Fix several broken logic in ->OriginalContent:

    - When $self->ContentEncoding eq 'quoted-printable', a premature
      "return" prevented any encoding conversion from taking place.

    - A bogus Encode::_utf8_on($content) later prevented any encoding
      conversino from taking place _anyway_.

* $attachment->Quote now respects RT::I18N::IsTextualContentType.


Modified: rt/branches/3.6-RELEASE/lib/RT/Attachment_Overlay.pm
==============================================================================
--- rt/branches/3.6-RELEASE/lib/RT/Attachment_Overlay.pm	(original)
+++ rt/branches/3.6-RELEASE/lib/RT/Attachment_Overlay.pm	Mon Nov 12 03:02:35 2007
@@ -276,8 +276,8 @@
 sub OriginalContent {
   my $self = shift;
 
-  return $self->Content unless (
-     $self->ContentType =~ qr{^(text/plain|message/rfc822)$}i) ;
+  return $self->Content unless RT::I18N::IsTextualContentType($self->ContentType);
+
   my $enc = $self->OriginalEncoding;
 
   my $content;
@@ -286,12 +286,15 @@
   } elsif ( $self->ContentEncoding eq 'base64' ) {
       $content = MIME::Base64::decode_base64($self->_Value('Content', decode_utf8 => 0));
   } elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
-      return MIME::QuotedPrint::decode($self->_Value('Content', decode_utf8 => 0));
+      $content = MIME::QuotedPrint::decode($self->_Value('Content', decode_utf8 => 0));
   } else {
       return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
   }
 
-   Encode::_utf8_on($content);
+  # Turn *off* the SvUTF8 bits here so decode_utf8 and from_to below can work.
+  local $@;
+  Encode::_utf8_off($content);
+
   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($content))} || return ($content);
@@ -356,7 +359,7 @@
 
     # TODO: Handle Multipart/Mixed (eventually fix the link in the
     # ShowHistory web template?)
-    if ($self->ContentType =~ m{^(text/plain|message)}i) {
+    if (RT::I18N::IsTextualContentType($self->ContentType)) {
 	$body=$self->Content;
 
 	# Do we need any preformatting (wrapping, that is) of the message?


More information about the Rt-commit mailing list