[Rt-commit] rt branch, 4.0/no-charset-for-binary-attach, created. rt-4.0.5-60-ge45f25d
? sunnavy
sunnavy at bestpractical.com
Thu Feb 9 23:42:30 EST 2012
The branch, 4.0/no-charset-for-binary-attach has been created
at e45f25d6842dfc0c4e5f6289e636e9eb294c019a (commit)
- Log -----------------------------------------------------------------
commit e45f25d6842dfc0c4e5f6289e636e9eb294c019a
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Feb 10 12:06:16 2012 +0800
not set charset in content-type if the attachment is binary
diff --git a/share/html/Ticket/Attachment/dhandler b/share/html/Ticket/Attachment/dhandler
index ec08294..b7235f3 100755
--- a/share/html/Ticket/Attachment/dhandler
+++ b/share/html/Ticket/Attachment/dhandler
@@ -79,7 +79,12 @@
my $enc = $AttachmentObj->OriginalEncoding || 'utf-8';
my $iana = Encode::find_encoding( $enc );
$iana = $iana? $iana->mime_name : $enc;
- $content_type .= ";charset=$iana";
+
+ require MIME::Types;
+ my $mimetype = MIME::Types->new->type($content_type);
+ unless ( $mimetype && $mimetype->isBinary ) {
+ $content_type .= ";charset=$iana";
+ }
$r->content_type( $content_type );
$m->clear_buffer();
diff --git a/t/web/attachments.t b/t/web/attachments.t
index 8c75f6c..5bee62c 100644
--- a/t/web/attachments.t
+++ b/t/web/attachments.t
@@ -1,10 +1,11 @@
#!/usr/bin/perl -w
use strict;
-use RT::Test tests => 25;
+use RT::Test tests => 30;
use constant LogoFile => $RT::MasonComponentRoot .'/NoAuth/images/bpslogo.png';
use constant FaviconFile => $RT::MasonComponentRoot .'/NoAuth/images/favicon.png';
+use constant TextFile => $RT::MasonComponentRoot .'/NoAuth/css/print.css';
my ($baseurl, $m) = RT::Test->started_ok;
ok $m->login, 'logged in';
@@ -32,7 +33,7 @@ $m->content_contains('Download bpslogo.png', 'page has file name');
$m->follow_link_ok({text => 'Reply'}, "reply to the ticket");
$m->form_name('TicketUpdate');
-$m->field('Attach', LogoFile);
+$m->field('Attach', TextFile);
$m->click('AddMoreAttach');
is($m->status, 200, "request successful");
@@ -44,7 +45,16 @@ is($m->status, 200, "request successful");
$m->content_contains('Download bpslogo.png', 'page has file name');
$m->content_contains('Download favicon.png', 'page has file name');
+$m->content_contains('Download print.css', 'page has file name');
+
+$m->follow_link_ok( { text => 'Download bpslogo.png' } );
+is( $m->response->header('Content-Type'), 'image/png', 'Content-Type of png lacks charset' );
+
+$m->back;
+$m->follow_link_ok( { text => 'Download print.css' } );
+is( $m->response->header('Content-Type'),
+ 'text/css;charset=UTF-8', 'Content-Type of text has charset' );
diag "test mobile ui";
$m->get_ok( $baseurl . '/m/ticket/create?Queue=' . $qid );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list