header-characters.t 2.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
use strict;
use warnings;

use RT::Test tests => 12;
use Test::Warn;
use utf8;
use Encode;

my ($baseurl, $m) = RT::Test->started_ok;

11
diag "Testing non-ASCII latin1 in From: header";
12
{
13
    my $mail = Encode::encode( 'iso-8859-1', <<'.' );
14
From: <René@example.com>
15
16
17
18
19
20
21
22
23
Reply-To: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
Subject: testing non-ASCII From
Content-Type: text/plain; charset=iso-8859-1

here's some content
.

    my ($status, $id);
    warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
24
        [(qr/Unable to parse an email address from/) x 2,
25
26
27
28
29
30
31
32
33
34
         qr/Couldn't parse or find sender's address/
        ],
        'Got parse error for non-ASCII in From';
    is( $status >> 8, 0, "The mail gateway exited normally" );
    TODO: {
          local $TODO = "Currently don't handle non-ASCII for sender";
          ok( $id, "Created ticket" );
      }
}

35
diag "Testing non-ASCII latin1 in From: header with MIME-word-encoded phrase";
36
{
37
    my $mail = Encode::encode( 'iso-8859-1', <<'.' );
38
39
40
41
42
43
44
45
46
47
From: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
Reply-To: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
Subject: testing non-ASCII From
Content-Type: text/plain; charset=iso-8859-1

here's some content
.

    my ($status, $id);
    warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
48
        [(qr/Unable to parse an email address from/) x 2,
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
         qr/Couldn't parse or find sender's address/
        ],
        'Got parse error for iso-8859-1 in From';
    is( $status >> 8, 0, "The mail gateway exited normally" );
    TODO: {
          local $TODO = "Currently don't handle non-ASCII in sender";
          ok( $id, "Created ticket" );
      }
}

diag "No sender";
{
    my $mail = <<'.';
To: rt@example.com
Subject: testing non-ASCII From
Content-Type: text/plain; charset=iso-8859-1

here's some content
.

    my ($status, $id);
    warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
71
        [qr/Couldn't parse or find sender's address/],
72
73
74
75
        'Got parse error with no sender fields';
    is( $status >> 8, 0, "The mail gateway exited normally" );
    ok( !$id, "No ticket created" );
}