[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-76-g73756bb

? sunnavy sunnavy at bestpractical.com
Sun Jun 6 00:32:02 EDT 2010


The branch, 3.8-trunk has been updated
       via  73756bbb6ce3e925713b03d783847f1f2f3db3c6 (commit)
      from  58dfb2bbe12cf3979ae1682842af2407cbbbdf78 (commit)

Summary of changes:
 lib/RT/EmailParser.pm |    5 ++-
 t/mail/outlook.t      |   62 +++++++++++++++++++++++++-----------------------
 2 files changed, 35 insertions(+), 32 deletions(-)

- Log -----------------------------------------------------------------
commit 73756bbb6ce3e925713b03d783847f1f2f3db3c6
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sun Jun 6 12:32:28 2010 +0800

    outlook 2010 has the same problem as 2007

diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 8c303f2..8f74784 100755
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -562,7 +562,7 @@ sub ParseEmailAddress {
 
 =head2 RescueOutlook 
 
-Outlook 2007 has a bug when you write an email with the html format.
+Outlook 2007/2010 have a bug when you write an email with the html format.
 it will send a 'multipart/alternative' with both 'text/plain' and 'text/html'
 in it.  it's cool to have a 'text/plain' part, but the problem is the part is
 not so right: all the "\n" in your main message will become "\n\n" :/
@@ -579,7 +579,8 @@ sub RescueOutlook {
     return unless $mime;
 
     my $mailer = $mime->head->get('X-Mailer');
-    if ( $mailer && $mailer =~ /Microsoft Office Outlook 12\./ ) {
+    # 12.0 is outlook 2007, 14.0 is 2010
+    if ( $mailer && $mailer =~ /Microsoft(?:.*?)Outlook 1[2-4]\./ ) {
         my $text_part;
         if ( $mime->head->get('Content-Type') =~ m{multipart/mixed} ) {
             my $first = $mime->parts(0);
diff --git a/t/mail/outlook.t b/t/mail/outlook.t
index 23706e6..15bfa21 100644
--- a/t/mail/outlook.t
+++ b/t/mail/outlook.t
@@ -56,13 +56,15 @@ rt-mailgate - Mail interface to RT3.
 use strict;
 use warnings;
 
-use RT::Test tests => 25;
+use RT::Test tests => 43;
 my ($baseurl, $m) = RT::Test->started_ok;
-diag "Test mail with multipart/alternative" if $ENV{'TEST_VERBOSE'};
-{
-    my $text = <<EOF;
+# 12.0 is outlook 2007, 14.0 is 2010
+for my $mailer ( 'Microsoft Office Outlook 12.0', 'Microsoft Outlook 14.0' ) {
+    diag "Test mail with multipart/alternative" if $ENV{'TEST_VERBOSE'};
+    {
+        my $text = <<EOF;
 From: root\@localhost
-X-Mailer: Microsoft Office Outlook 12.0
+X-Mailer: $mailer
 To: rt\@@{[RT->Config->Get('rtname')]}
 Subject: outlook basic test
 Content-Type: multipart/alternative;
@@ -94,27 +96,26 @@ Content-Transfer-Encoding: quoted-printable
 
 EOF
 
-    my $content = <<EOF;
+        my $content = <<EOF;
 here is the content
 
 blahmm
 another line
 EOF
-    test_email( $text, $content,
-        'outlook with multipart/alternative, \n\n will not be replaced' );
-}
-
-diag "Test mail with multipart/mixed, with multipart/alternative in it"
-  if $ENV{'TEST_VERBOSE'};
-{
-    my $text = <<EOF;
+        test_email( $text, $content,
+            $mailer . ' with multipart/alternative, \n\n are replaced' );
+    }
+
+    diag "Test mail with multipart/mixed, with multipart/alternative in it"
+      if $ENV{'TEST_VERBOSE'};
+    {
+        my $text = <<EOF;
 From: root\@localhost
-X-Mailer: Microsoft Office Outlook 12.0
+X-Mailer: $mailer
 To: rt\@@{[RT->Config->Get('rtname')]}
 Subject: outlook basic test
 Content-Type: multipart/mixed;
 	boundary="----=_NextPart_000_000F_01CB045E.5222CB40"
-X-Mailer: Microsoft Office Outlook 12.0
 
 ------=_NextPart_000_000F_01CB045E.5222CB40
 Content-Type: multipart/alternative;
@@ -156,22 +157,22 @@ this is the attachment! :)=0A=
 ------=_NextPart_000_000F_01CB045E.5222CB40--
 EOF
 
-    my $content = <<EOF;
+        my $content = <<EOF;
 foo
 
 bar
 baz
 EOF
-    test_email( $text, $content,
-        'outlook with multipart/multipart, \n\n will not be replaced' );
-}
-
-diag "Test mail with with outlook, but the content type is text/plain"
-  if $ENV{'TEST_VERBOSE'};
-{
-    my $text = <<EOF;
+        test_email( $text, $content,
+            $mailer . ' with multipart/multipart, \n\n are replaced' );
+    }
+
+    diag "Test mail with with outlook, but the content type is text/plain"
+      if $ENV{'TEST_VERBOSE'};
+    {
+        my $text = <<EOF;
 From: root\@localhost
-X-Mailer: Mutt
+X-Mailer: $mailer
 To: rt\@@{[RT->Config->Get('rtname')]}
 Subject: outlook basic test
 Content-Type: text/plain; charset="us-ascii"
@@ -187,7 +188,7 @@ baz
 
 EOF
 
-    my $content = <<EOF;
+        my $content = <<EOF;
 foo
 
 
@@ -197,8 +198,9 @@ bar
 baz
 
 EOF
-    test_email( $text, $content,
-        'outlook with only text/plain, \n\n will not be replaced' );
+        test_email( $text, $content,
+            $mailer . ' with only text/plain, \n\n are not replaced' );
+    }
 }
 
 diag "Test mail with with multipart/alternative but x-mailer is not outlook "
@@ -248,7 +250,7 @@ bar
 baz
 
 EOF
-    test_email( $text, $content, 'without outlook, \n\n will not be replaced' );
+    test_email( $text, $content, 'without outlook, \n\n are not replaced' );
 }
 
 sub test_email {

-----------------------------------------------------------------------


More information about the Rt-commit mailing list