[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-135-g3adb6b7
? sunnavy
sunnavy at bestpractical.com
Tue Aug 17 06:48:37 EDT 2010
The branch, 3.8-trunk has been updated
via 3adb6b75ae2601faea3d33ad5b2f9ec43f72dbee (commit)
via 5206cbda8d370834a5c588e2030bea2020819f33 (commit)
via 388f70f9c93b82d5b49fbf85739c1f675037f674 (commit)
from 45fdf505109d201dd676354ff9c07184c9cc3a30 (commit)
Summary of changes:
share/html/Ticket/Attachment/WithHeaders/dhandler | 10 +-
share/html/Ticket/Attachment/dhandler | 9 +-
.../Ticket/Elements/ShowTransactionAttachments | 2 +-
t/web/attachment_encoding.t | 99 ++++++++++++++++++++
4 files changed, 108 insertions(+), 12 deletions(-)
create mode 100644 t/web/attachment_encoding.t
- Log -----------------------------------------------------------------
commit 388f70f9c93b82d5b49fbf85739c1f675037f674
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Aug 17 17:06:34 2010 +0800
warning fix: ContentLength maybe empty
diff --git a/share/html/Ticket/Elements/ShowTransactionAttachments b/share/html/Ticket/Elements/ShowTransactionAttachments
index be791b7..9903ca4 100644
--- a/share/html/Ticket/Elements/ShowTransactionAttachments
+++ b/share/html/Ticket/Elements/ShowTransactionAttachments
@@ -244,7 +244,7 @@ my $render_attachment = sub {
. $message->Id
. '/" />' );
}
- elsif ( $message->ContentLength > 0 ) {
+ elsif ( $message->ContentLength && $message->ContentLength > 0 ) {
$m->out( '<p>' .
loc( 'Message body not shown because it is not plain text.' ) .
'</p>'
commit 5206cbda8d370834a5c588e2030bea2020819f33
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Aug 17 17:33:17 2010 +0800
test for /Ticket/Attachment/*
diff --git a/t/web/attachment_encoding.t b/t/web/attachment_encoding.t
new file mode 100644
index 0000000..85c5bbc
--- /dev/null
+++ b/t/web/attachment_encoding.t
@@ -0,0 +1,99 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 22;
+use Encode;
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok $m->login, 'logged in as root';
+
+$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
+
+use utf8;
+
+use File::Spec;
+
+diag 'test without attachments' if $ENV{TEST_VERBOSE};
+
+{
+ $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
+
+ $m->form_number(3);
+ $m->submit_form(
+ form_number => 3,
+ fields => { Subject => 'æ é¢', Content => 'æµè¯' },
+ );
+ $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+ $m->follow_link_ok( { text => 'with headers' },
+ '-> /Ticket/Attachment/WithHeaders/...' );
+ $m->content_contains( 'æ é¢', 'has subject æ é¢' );
+ $m->content_contains( 'æµè¯', 'has content æµè¯' );
+
+ my ( $id ) = $m->uri =~ /(\d+)$/;
+ ok( $id, 'found attachment id' );
+ my $attachment = RT::Attachment->new( $RT::SystemUser );
+
+ # let make original encoding to gbk
+ $attachment->AddHeader( 'X-RT-Original-Encoding' => 'gbk' );
+ $m->get( $m->uri );
+ $m->content_contains( 'æ é¢', 'has subject æ é¢' );
+ $m->content_contains( 'æµè¯', 'has content æµè¯' );
+}
+
+diag 'test with attachemnts' if $ENV{TEST_VERBOSE};
+
+{
+
+ my $file =
+ File::Spec->catfile( File::Spec->tmpdir, 'rt_attachemnt_abcde.txt' );
+ open my $fh, '>', $file or die $!;
+ binmode $fh, ':utf8';
+ print $fh 'é件';
+ close $fh;
+
+ $m->get_ok( $baseurl . '/Ticket/Create.html?Queue=1' );
+
+ $m->form_number(3);
+ $m->submit_form(
+ form_number => 3,
+ fields => { Subject => 'æ é¢', Content => 'æµè¯', Attach => $file },
+ );
+ $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' );
+ $m->follow_link_ok( { text => 'with headers' },
+ '-> /Ticket/Attachment/WithHeaders/...' );
+
+ # subject is in the parent attachment, so there is no æ é¢
+ $m->content_lacks( 'æ é¢', 'does not have content æ é¢' );
+ $m->content_contains( 'æµè¯', 'has content æµè¯' );
+
+ my ( $id ) = $m->uri =~ /(\d+)$/;
+ ok( $id, 'found attachment id' );
+ my $attachment = RT::Attachment->new( $RT::SystemUser );
+
+ # let make original encoding to gbk
+ $attachment->AddHeader( 'X-RT-Original-Encoding' => 'gbk' );
+ $m->get( $m->uri );
+ $m->content_lacks( 'æ é¢', 'does not have content æ é¢' );
+ $m->content_contains( 'æµè¯', 'has content æµè¯' );
+
+
+ $m->back;
+ $m->back;
+ $m->follow_link_ok( { text_regex => qr/by root/ },
+ '-> /Ticket/Attachment/...' );
+ $m->content_contains( 'é件', 'has content é件' );
+
+ ( $id ) = $m->uri =~ /(\d+)\D+$/;
+ ok( $id, 'found attachment id' );
+ $attachment = RT::Attachment->new( $RT::SystemUser );
+
+ # let make original encoding to gbk
+ $attachment->AddHeader( 'X-RT-Original-Encoding' => 'gbk' );
+ $m->get( $m->uri );
+ $m->content_contains( 'é件', 'has content é件' );
+
+ unlink $file;
+}
+
+
commit 3adb6b75ae2601faea3d33ad5b2f9ec43f72dbee
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Aug 17 18:05:43 2010 +0800
make charset to utf-8 by default in /Ticket/Attachment/*
diff --git a/share/html/Ticket/Attachment/WithHeaders/dhandler b/share/html/Ticket/Attachment/WithHeaders/dhandler
index 7df1ae8..bfc74d9 100644
--- a/share/html/Ticket/Attachment/WithHeaders/dhandler
+++ b/share/html/Ticket/Attachment/WithHeaders/dhandler
@@ -60,12 +60,10 @@
}
my $content_type = 'text/plain';
- my $enc = $AttachmentObj->OriginalEncoding;
- if ( $enc ) {
- my $iana = Encode::find_encoding($enc);
- $iana = $iana ? $iana->mime_name : $enc;
- $content_type .= ";charset=$iana";
- }
+ my $enc = $AttachmentObj->OriginalEncoding || 'utf-8';
+ my $iana = Encode::find_encoding($enc);
+ $iana = $iana ? $iana->mime_name : $enc;
+ $content_type .= ";charset=$iana";
# XXX: should we check handle html here and integrate headers into html?
$r->content_type( $content_type );
diff --git a/share/html/Ticket/Attachment/dhandler b/share/html/Ticket/Attachment/dhandler
index 6c4d191..d83bf00 100755
--- a/share/html/Ticket/Attachment/dhandler
+++ b/share/html/Ticket/Attachment/dhandler
@@ -76,11 +76,10 @@
$content_type = 'text/plain' if ($content_type =~ /^text\/html/i);
}
- if (my $enc = $AttachmentObj->OriginalEncoding) {
- my $iana = Encode::find_encoding( $enc );
- $iana = $iana? $iana->mime_name : $enc;
- $content_type .= ";charset=$iana";
- }
+ my $enc = $AttachmentObj->OriginalEncoding || 'utf-8';
+ my $iana = Encode::find_encoding( $enc );
+ $iana = $iana? $iana->mime_name : $enc;
+ $content_type .= ";charset=$iana";
# unless (RT->Config->Get('TrustMIMEAttachments')) {
# $content_type = 'application/octet-stream';
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list