[Rt-commit] rt branch, 4.0/emailparser-false-positives, created. rt-4.0.3-17-ge50515e

Jason May jasonmay at bestpractical.com
Mon Nov 14 10:37:07 EST 2011


The branch, 4.0/emailparser-false-positives has been created
        at  e50515e9291ebc57524bac135fbe0f4291248774 (commit)

- Log -----------------------------------------------------------------
commit e50515e9291ebc57524bac135fbe0f4291248774
Author: Jason May <jasonmay at bestpractical.com>
Date:   Tue Nov 8 14:47:18 2011 -0500

    Do not count an empty string as a valid RT email address
    
    Though technically it maps to a user of that value, it is technically
    not a valid email address and happens often, so it's worth making an
    special case to skip these.

diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index fc25f57..d2c84de 100644
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -342,6 +342,8 @@ sub IsRTAddress {
         return 1 if lc $comment_address eq lc $address;
     }
 
+    return undef unless length($address);
+
     my $queue = RT::Queue->new( RT->SystemUser );
     $queue->LoadByCols( CorrespondAddress => $address );
     return 1 if $queue->id;
diff --git a/t/api/emailparser.t b/t/api/emailparser.t
index 7903146..bc81e7c 100644
--- a/t/api/emailparser.t
+++ b/t/api/emailparser.t
@@ -2,13 +2,21 @@
 use strict;
 use warnings;
 
-use RT::Test nodb => 1, tests => 10;
-
-RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
+use RT::Test tests => 11;
 
+# create a user with a blank email address
+RT::Test->load_or_create_user(
+    Name => 'testuser',
+    EmailAddress => '',
+);
 
 ok(require RT::EmailParser);
 
+RT->Config->Set( RTAddressRegexp => undef );
+is(RT::EmailParser::IsRTAddress("",""),undef, "Empty emails don't match users without email addresses" );
+
+RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
+
 is(RT::EmailParser::IsRTAddress("","rt\@example.com"),1, "Regexp matched rt address" );
 is(RT::EmailParser::IsRTAddress("","frt\@example.com"),undef, "Regexp didn't match non-rt address" );
 

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


More information about the Rt-commit mailing list