diff options
author | Dianne Skoll <dianne@bestpractical.com> | 2021-01-20 17:09:26 +0300 |
---|---|---|
committer | Dianne Skoll <dianne@bestpractical.com> | 2021-01-20 17:09:26 +0300 |
commit | 19954bf377035ccf558038a9cadd79fb1fb874d3 (patch) | |
tree | ef7bbd6b78d3282e72f85347138c04c134d4d729 | |
parent | 65f716e01c4ac1edc930cf0b0e4819e5588539cb (diff) |
Add test for cleaning up MS Outlook HTML mail.5.0/clean-up-email-for-replying
-rw-r--r-- | t/api/transaction-quoting.t | 26 | ||||
-rw-r--r-- | t/data/emails/ms-outlook/expected-output-1 | 21 | ||||
-rw-r--r-- | t/data/emails/ms-outlook/input-msg-1 | 39 |
3 files changed, 85 insertions, 1 deletions
diff --git a/t/api/transaction-quoting.t b/t/api/transaction-quoting.t index bf42c1be99..7d54d62ea7 100644 --- a/t/api/transaction-quoting.t +++ b/t/api/transaction-quoting.t @@ -2,7 +2,7 @@ use strict; use warnings; use RT; -use RT::Test tests => 28; +use RT::Test tests => 31; use_ok('RT::Transaction'); @@ -363,6 +363,30 @@ QUOTED $content = $txn->Content(Quote => 1); like($content, qr/\Q$expected/, 'Spurious newlines were not removed from non-Outlook email'); + # HTML mail + { + local $/; + open(my $fh, '<t/data/emails/ms-outlook/input-msg-1') or die("Cannot read t/data/emails/ms-outlook/input-msg-1: $!"); + $mail = <$fh>; + close($fh); + } + { + local $/; + open(my $fh, '<t/data/emails/ms-outlook/expected-output-1') or die("Cannot read t/data/emails/ms-outlook/expected-output-1: $!"); + $expected = <$fh>; + close($fh); + } + ( $status, $id ) = RT::Test->send_via_mailgate($mail); + is( $status >> 8, 0, "The mail gateway exited normally" ); + ok( $id, "Created ticket $id" ); + $ticket = RT::Ticket->new( RT->SystemUser ); + $ticket->Load( $id ); + $txns = $ticket->Transactions; + $txn = $txns->Next; + $content = $txn->Content(Quote => 1, Type => 'text/html'); + like($content, qr/\Q$expected/, 'HTML mail was cleaned as expected'); } + + diff --git a/t/data/emails/ms-outlook/expected-output-1 b/t/data/emails/ms-outlook/expected-output-1 new file mode 100644 index 0000000000..5dcb43b949 --- /dev/null +++ b/t/data/emails/ms-outlook/expected-output-1 @@ -0,0 +1,21 @@ + + + + +<div><font color="#ff0000" size="2"><b>[External Email]</b></font></div> + + +<div> +<div class="WordSection1"> +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060">Hi,<o:p></o:p></span></p> + +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060">A normal line<o:p></o:p></span></p> + + +<p class="MsoNormal"><span lang="EN-GB" style="font-size:8.0pt;font-family:"Calibri Light",sans-serif;color:#002060">Regards,<o:p></o:p></span></p> + + +</div> +</div> + +</blockquote></div>
\ No newline at end of file diff --git a/t/data/emails/ms-outlook/input-msg-1 b/t/data/emails/ms-outlook/input-msg-1 new file mode 100644 index 0000000000..0af3ce7b24 --- /dev/null +++ b/t/data/emails/ms-outlook/input-msg-1 @@ -0,0 +1,39 @@ +From: root@localhost +X-Mailer: Microsoft Office Outlook 12.0 +To: rt@example.com +Subject: outlook basic test +Date: Fri, 1 Jan 2021 15:49:21 -0500 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0004_01CB045C.A5A075D0" + +------=_NextPart_000_0004_01CB045C.A5A075D0 +content-type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + +<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"> +<head> +<meta name="Generator" content="Microsoft Word 15 (filtered medium)"> +</head> +<body lang="EN-US" link="blue" vlink="purple"> +<div><font color="#ff0000" size="2"><b>[External Email]</b></font></div> +<div><br> +</div> +<div><br> +</div> +<div> +<div class="WordSection1"> +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060">Hi,<o:p></o:p></span></p> +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060"><o:p> </o:p></span></p> +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060">A normal line<o:p></o:p></span></p> +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060"><o:p> </o:p></span></p> +<p class="MsoNormal"><span style="font-size:10.0pt;font-family:DengXian;color:#002060"><o:p> </o:p></span></p> +<p class="MsoNormal"><span lang="EN-GB" style="font-size:8.0pt;font-family:"Calibri Light",sans-serif;color:#002060">Regards,<o:p></o:p></span></p> +<p class="MsoNormal"><span lang="EN-GB" style="font-size:8.0pt;font-family:"Calibri Light",sans-serif;color:#002060"><o:p> </o:p></span></p> +<p class="MsoNormal"><span lang="EN-GB" style="font-size:8.0pt;font-family:"Calibri Light",sans-serif;color:#002060"><o:p> </o:p></span></p> +</div> +</div> +</body> +</html> +------=_NextPart_000_0004_01CB045C.A5A075D0-- + |