diff options
author | Ivan Kohler <ivan@freeside.biz> | 2014-09-15 20:44:48 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2014-09-15 20:44:48 -0700 |
commit | ed1f84b4e8f626245995ecda5afcf83092c153b2 (patch) | |
tree | 3f58bbef5fbf2502e65d29b37b5dbe537519e89d /rt/t/mail/header-characters.t | |
parent | fe9ea9183e8a16616d6d04a7b5c7498d28e78248 (diff) |
RT 4.0.22
Diffstat (limited to 'rt/t/mail/header-characters.t')
-rw-r--r-- | rt/t/mail/header-characters.t | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/rt/t/mail/header-characters.t b/rt/t/mail/header-characters.t new file mode 100644 index 000000000..004ba8522 --- /dev/null +++ b/rt/t/mail/header-characters.t @@ -0,0 +1,81 @@ +use strict; +use warnings; + +use RT::Test tests => 12; +use Test::Warn; + +my ($baseurl, $m) = RT::Test->started_ok; + +diag "Testing non-ASCII in From: header"; +SKIP:{ + skip "Test requires Email::Address 1.893 or later, " + . "you have $Email::Address::VERSION", 3, + if $Email::Address::VERSION < 1.893; + + my $mail = Encode::encode( 'iso-8859-1', Encode::decode( "UTF-8", <<'.') ); +From: 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) } + [qr/Failed to parse Reply-To:.*, From:/, + 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" ); + } +} + +diag "Testing iso-8859-1 encoded non-ASCII in From: header"; +SKIP:{ + skip "Test requires Email::Address 1.893 or later, " + . "you have $Email::Address::VERSION", 3, + if $Email::Address::VERSION < 1.893; + + my $mail = Encode::encode( 'iso-8859-1', Encode::decode( "UTF-8", <<'.' ) ); +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) } + [qr/Failed to parse Reply-To:.*, From:/, + 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) } + [qr/Couldn't parse or find sender's address/], + 'Got parse error with no sender fields'; + is( $status >> 8, 0, "The mail gateway exited normally" ); + ok( !$id, "No ticket created" ); +} |