[Rt-commit] rt branch, 4.0/originalcontent-refactor, created. rt-4.0.22-22-ge529e4d

Alex Vandiver alexmv at bestpractical.com
Wed Dec 10 18:02:33 EST 2014


The branch, 4.0/originalcontent-refactor has been created
        at  e529e4d55571dd352b79c345e8ce30da65a0d860 (commit)

- Log -----------------------------------------------------------------
commit e529e4d55571dd352b79c345e8ce30da65a0d860
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Dec 10 17:57:40 2014 -0500

    Remove duplicated content-encoding handling in OriginalContent
    
    The code in OriginalContent mirrors that of _DecodeLOB, merely differing
    in that it skips the character decoding step.  This behavior can be
    skipped, however, by passing a binary Content-Type, which is otherwise
    irrelevant to _DecodeLOB.
    
    Removing the duplicated code leaves one unified codepath controlling
    content encoding handling.

diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 5c90564..66a76fb 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -318,16 +318,11 @@ sub OriginalContent {
 
     return $self->Content unless RT::I18N::IsTextualContentType($self->ContentType);
 
-    my $content;
-    if ( !$self->ContentEncoding || $self->ContentEncoding eq 'none' ) {
-        $content = $self->_Value('Content', decode_utf8 => 0);
-    } elsif ( $self->ContentEncoding eq 'base64' ) {
-        $content = MIME::Base64::decode_base64($self->_Value('Content', decode_utf8 => 0));
-    } elsif ( $self->ContentEncoding eq 'quoted-printable' ) {
-        $content = MIME::QuotedPrint::decode($self->_Value('Content', decode_utf8 => 0));
-    } else {
-        return( $self->loc("Unknown ContentEncoding [_1]", $self->ContentEncoding));
-    }
+    my $content = $self->_DecodeLOB(
+        "application/octet-stream", # Force _DecodeLOB to not decode to characters
+        $self->ContentEncoding,
+        $self->_Value('Content', decode_utf8 => 0),
+    );
 
     my $entity = MIME::Entity->new();
     $entity->head->add("Content-Type", $self->GetHeader("Content-Type"));

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


More information about the rt-commit mailing list