[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.9.6-357-gcb32d9a

? sunnavy sunnavy at bestpractical.com
Mon Dec 6 00:31:33 EST 2010


The branch, 3.9-trunk has been updated
       via  cb32d9a66c5e9b8c6de05a7087962c9a398cba30 (commit)
      from  0ab2a5ffcee3cb8fe32184c72a511235edca6eed (commit)

Summary of changes:
 lib/RT/Interface/Email.pm |    7 +------
 t/api/emailparser.t       |   20 +++++++++++++++++++-
 2 files changed, 20 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit cb32d9a66c5e9b8c6de05a7087962c9a398cba30
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Dec 6 13:29:05 2010 +0800

    returned name should be only from phrase for RT::Interface::Email::ParseAddressFromHeader

diff --git a/lib/RT/Interface/Email.pm b/lib/RT/Interface/Email.pm
index 92d3022..f5168c0 100755
--- a/lib/RT/Interface/Email.pm
+++ b/lib/RT/Interface/Email.pm
@@ -1102,12 +1102,7 @@ sub ParseAddressFromHeader {
         return ( undef, undef );
     }
 
-    my $Name = ( $AddrObj->name || $AddrObj->phrase || $AddrObj->comment || $AddrObj->address );
-
-    #Lets take the from and load a user object.
-    my $Address = $AddrObj->address;
-
-    return ( $Address, $Name );
+    return ( $AddrObj->address, $AddrObj->phrase );
 }
 
 =head2 DeleteRecipientsFromHead HEAD RECIPIENTS
diff --git a/t/api/emailparser.t b/t/api/emailparser.t
index 29550bd..7903146 100644
--- a/t/api/emailparser.t
+++ b/t/api/emailparser.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use RT::Test nodb => 1, tests => 4;
+use RT::Test nodb => 1, tests => 10;
 
 RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
 
@@ -16,3 +16,21 @@ my @before = ("rt\@example.com", "frt\@example.com");
 my @after = ("frt\@example.com");
 ok(eq_array(RT::EmailParser->CullRTAddresses(@before), at after), "CullRTAddresses only culls RT addresses");
 
+{
+    require RT::Interface::Email;
+    my ( $addr, $name ) =
+      RT::Interface::Email::ParseAddressFromHeader('foo at example.com');
+    is( $addr, 'foo at example.com', 'addr for foo at example.com' );
+    is( $name, undef,             'no name for foo at example.com' );
+
+    ( $addr, $name ) =
+      RT::Interface::Email::ParseAddressFromHeader('Foo <foo at example.com>');
+    is( $addr, 'foo at example.com', 'addr for Foo <foo at example.com>' );
+    is( $name, 'Foo',             'name for Foo <foo at example.com>' );
+
+    ( $addr, $name ) =
+      RT::Interface::Email::ParseAddressFromHeader('foo at example.com (Comment)');
+    is( $addr, 'foo at example.com', 'addr for foo at example.com (Comment)' );
+    is( $name, undef,             'no name for foo at example.com (Comment)' );
+}
+

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


More information about the Rt-commit mailing list