summaryrefslogtreecommitdiff
path: root/rt/t/mail/wrong_mime_charset.t
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2012-04-24 11:35:56 -0700
committerIvan Kohler <ivan@freeside.biz>2012-04-24 11:35:56 -0700
commit6587f6ba7d047ddc1686c080090afe7d53365bd4 (patch)
treeec77342668e8865aca669c9b4736e84e3077b523 /rt/t/mail/wrong_mime_charset.t
parent47153aae5c2fc00316654e7277fccd45f72ff611 (diff)
first pass RT4 merge, RT#13852
Diffstat (limited to 'rt/t/mail/wrong_mime_charset.t')
-rw-r--r--rt/t/mail/wrong_mime_charset.t21
1 files changed, 20 insertions, 1 deletions
diff --git a/rt/t/mail/wrong_mime_charset.t b/rt/t/mail/wrong_mime_charset.t
index 71a574f26..511a7e61d 100644
--- a/rt/t/mail/wrong_mime_charset.t
+++ b/rt/t/mail/wrong_mime_charset.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
-use RT::Test nodata => 1, tests => 3;
+use RT::Test nodb => 1, tests => 6;
use_ok('RT::I18N');
use utf8;
@@ -16,12 +16,31 @@ my $mime = MIME::Entity->build(
# set the wrong charset mime in purpose
$mime->head->mime_attr( "Content-Type.charset" => 'utf8' );
+my @warnings;
+local $SIG{__WARN__} = sub {
+ push @warnings, "@_";
+};
+
RT::I18N::SetMIMEEntityToEncoding( $mime, 'iso-8859-1' );
TODO: {
local $TODO =
'need a better approach of encoding converter, should be fixed in 4.2';
+# this is a weird behavior for different perl versions, 5.12 warns twice,
+# which is correct since we do the encoding thing twice, for Subject
+# and Data respectively.
+# but 5.8 and 5.10 warns only once.
+ok( @warnings == 1 || @warnings == 2, "1 or 2 warnings are ok" );
+ok( @warnings == 1 || ( @warnings == 2 && $warnings[1] eq $warnings[0] ),
+ 'if there are 2 warnings, they should be same' );
+
+like(
+ $warnings[0],
+ qr/\QEncoding error: "\x{fffd}" does not map to iso-8859-1/,
+"We can't encode something into the wrong encoding without Encode complaining"
+);
+
my $subject = decode( 'iso-8859-1', $mime->head->get('Subject') );
chomp $subject;
is( $subject, $test_string, 'subject is set to iso-8859-1' );