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::Test tests => undef;
use Test::Warn;
my $queue = RT::Test->load_or_create_queue( Name => 'General' );
ok $queue->id, 'loaded queue';
{
my $mail = <<'END';
From: root@localhost
Subject: test
Content-type: text/plain; charset="not-supported-encoding"
ho hum just some text
END
my ($stat, $id);
warning_like {
($stat, $id) = RT::Test->send_via_mailgate($mail);
is( $stat >> 8, 0, "The mail gateway exited normally" );
ok( $id, "created ticket" );
} qr/Encoding 'not-supported-encoding' is not supported/;
my $ticket = RT::Ticket->new( RT->SystemUser );
$ticket->Load($id);
ok $ticket->id, "loaded ticket";
my $txn = $ticket->Transactions->First;
ok !$txn->ContentObj, 'no content';
my $attach = $txn->Attachments->First;
like $attach->Content, qr{ho hum just some text}, 'attachment is there';
is $attach->GetHeader('Content-Type'),
'application/octet-stream; charset="not-supported-encoding"',
'content type is changed'
;
is $attach->GetHeader('X-RT-Original-Content-Type'),
'text/plain',
'original content type is saved'
;
}
{
my $mail = <<'END';
From: root@localhost
Subject: =?not-supported?Q?=07test=A9?=
Content-type: text/plain; charset="ascii"
ho hum just some text
END
my ($stat, $id);
warning_like {
($stat, $id) = RT::Test->send_via_mailgate($mail);
is( $stat >> 8, 0, "The mail gateway exited normally" );
ok( $id, "created ticket" );
} qr/Charset 'not-supported' is not supported/;
my $ticket = RT::Ticket->new( RT->SystemUser );
$ticket->Load($id);
ok $ticket->id, "loaded ticket";
is $ticket->Subject, "\x{FFFD}test\x{FFFD}";
}
done_testing;
|