1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
use strict;
use warnings;
use RT;
use RT::Test tests => 7;
{
ok (require RT::Attachment);
}
{
my $test1 = "From: jesse";
my @headers = RT::Attachment->_SplitHeaders($test1);
is ($#headers, 0, $test1 );
my $test2 = qq{From: jesse
To: bobby
Subject: foo
};
@headers = RT::Attachment->_SplitHeaders($test2);
is ($#headers, 2, "testing a bunch of singline multiple headers" );
my $test3 = qq{From: jesse
To: bobby,
Suzie,
Sally,
Joey: bizzy,
Subject: foo
};
@headers = RT::Attachment->_SplitHeaders($test3);
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;
|