[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-129-ga17642a
? sunnavy
sunnavy at bestpractical.com
Fri Aug 13 21:00:41 EDT 2010
The branch, 3.8-trunk has been updated
via a17642ae74a8f3f6ee53c2dd4b70ebdb89b63c93 (commit)
from 5107a7901eb5d2c9e76b1685b9240385e031db7b (commit)
Summary of changes:
lib/RT/Attachment_Overlay.pm | 5 +++++
t/api/attachment.t | 26 +++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletions(-)
- Log -----------------------------------------------------------------
commit a17642ae74a8f3f6ee53c2dd4b70ebdb89b63c93
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sat Aug 14 09:01:29 2010 +0800
make ContentAsMIME head's Content-Type.charset consistent with body
diff --git a/lib/RT/Attachment_Overlay.pm b/lib/RT/Attachment_Overlay.pm
index 3a87d7e..728adde 100644
--- a/lib/RT/Attachment_Overlay.pm
+++ b/lib/RT/Attachment_Overlay.pm
@@ -425,6 +425,11 @@ sub ContentAsMIME {
my ($h_key, $h_val) = split /:/, $header, 2;
$entity->head->add( $h_key, RT::Interface::Email::EncodeToMIME( String => $h_val ) );
}
+
+ # since we want to return original content, let's use original encoding
+ $entity->head->mime_attr(
+ "Content-Type.charset" => $self->OriginalEncoding )
+ if $self->OriginalEncoding;
use MIME::Body;
$entity->bodyhandle(
diff --git a/t/api/attachment.t b/t/api/attachment.t
index 07c46ba..282d2a3 100644
--- a/t/api/attachment.t
+++ b/t/api/attachment.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
use RT;
-use RT::Test tests => 4;
+use RT::Test tests => 7;
{
@@ -42,4 +42,28 @@ is ($#headers, 2, "testing a bunch of singline multiple headers" );
}
+
+{
+ my $iso_8859_1_ticket_email =
+ RT::Test::get_relocatable_file( 'new-ticket-from-iso-8859-1',
+ ( File::Spec->updir(), 'data', 'emails' ) );
+ my $content = RT::Test->file_content($iso_8859_1_ticket_email);
+
+ my $parser = RT::EmailParser->new;
+ $parser->ParseMIMEEntityFromScalar($content);
+ my $attachment = RT::Attachment->new( $RT::SystemUser );
+ my ( $id, $msg ) =
+ $attachment->Create( TransactionId => 1, Attachment => $parser->Entity );
+ ok( $id, $msg );
+ my $mime = $attachment->ContentAsMIME;
+ like( $mime->head->get('Content-Type'),
+ qr/charset="iso-8859-1"/, 'content type of ContentAsMIME is original' );
+ require Encode;
+ is(
+ Encode::decode( 'iso-8859-1', $mime->stringify_body ),
+ Encode::decode( 'utf8', "HÃ¥vard\n" ),
+ 'body of ContentAsMIME is original'
+ );
+}
+
1;
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list