From e2e2de23c713a1b84ba0e1ab57dc26b1846cc614 Mon Sep 17 00:00:00 2001 From: David Flatz Date: Mon, 28 Apr 2014 15:13:16 +0200 Subject: introduce new function addrlist_escape that uses header_escape to only escape realname part of address lists --- tests/it_mail.t | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/it_mail.t b/tests/it_mail.t index 181c3df..1762788 100755 --- a/tests/it_mail.t +++ b/tests/it_mail.t @@ -7,7 +7,7 @@ $mail = new it_mail(); # header_escape tests # is( - $mail->header_escape('éxample@example.com', true), + $mail->addrlist_escape('éxample@example.com', true), 'éxample@example.com', "Don't escape plain email addresses in email headers", ); @@ -19,25 +19,64 @@ is( ); is( - $mail->header_escape('Èxample User <èxample@example.com>', true), + $mail->addrlist_escape('Èxample User <èxample@example.com>', true), '=?utf-8?Q?=C3=88xample_User?= <èxample@example.com>', "Escape name but not email in email headers", ); is( - $mail->header_escape('Example User ', true), + $mail->addrlist_escape('Example User ', true), 'Example User ', "Don't escape characters that don't need escaping" ); is( - $mail->header_escape('example@example.com, éxample@example.com, Sömeone Ëlse ', true), + $mail->addrlist_escape('example@example.com, éxample@example.com, Sömeone Ëlse ', true), 'example@example.com, éxample@example.com,=?utf-8?Q?_S=C3=B6meone_=C3=8Blse?= ', "Don't escape email addresses but escape realnames", ); is( - $mail->header_escape('"Alfred E. Neuman" ', true), + $mail->addrlist_escape('"Alfred E. Neuman" ', true), '"Alfred E. Neuman" ', "Don't remove quoting characters from realname", ); + + +$mail = new it_mail( + 'From' => 'Someone Ïmportant <ïmportant@search.ch>', + 'To' => 'éxample@example.com, example@example.com, Sömeone Ëlse , "Alfred E. Neuman" ', + 'Cc' => 'éxample@example.com, example@example.com, Sömeone Ëlse , "Alfred E. Neuman" ', + 'Bcc' => 'éxample@example.com, example@example.com, Sömeone Ëlse , "Alfred E. Neuman" ', + 'Subject' => "§önÐë®z€ı¢ħèṇ", +); + +is( + $mail->to[0], + 'éxample@example.com, example@example.com,=?utf-8?Q?_S=C3=B6meone_=C3=8Blse?= , "Alfred E. Neuman" ', + 'Escape To: field as addrlist', +); + +is( + $mail->cc[0], + 'éxample@example.com, example@example.com,=?utf-8?Q?_S=C3=B6meone_=C3=8Blse?= , "Alfred E. Neuman" ', + 'Escape Cc: field as addrlist', +); + +is( + $mail->bcc[0], + 'éxample@example.com, example@example.com,=?utf-8?Q?_S=C3=B6meone_=C3=8Blse?= , "Alfred E. Neuman" ', + 'Escape Bcc: field as addrlist', +); + +is( + $mail->header_values[0], + '=?utf-8?Q?Someone_=C3=8Fmportant?= <ïmportant@search.ch>', + 'Escape From: field as addrlist', +); + +is( + $mail->subject, + "§önÐë®z€ı¢ħèṇ", + "Don't escape Subject: field on instanziation", +); -- cgit v1.2.3