[Rt-commit] rt branch, 4.0/emailparser-false-positives, created. rt-4.0.6-218-g65127b3

Alex Vandiver alexmv at bestpractical.com
Wed Jun 27 22:24:45 EDT 2012


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

- Log -----------------------------------------------------------------
commit 65127b3349f124ec44e8f82d2222cc8a67739bcb
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Jun 27 22:19:32 2012 -0400

    Empty emails should not match empty Correspond addresses on Queues
    
    The value stored in the database for "the default global Correspond
    address" is the empty string.  This caused the IsRTAddress code to
    false-positive when passed the empty string, such as from a user with no
    email address set.  While such addresses should indeed be removed,
    catching them in IsRTAddress caused unnecessary warnings in the logs.
    
    See issue #18380.

diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index 4cf4184..af4e396 100644
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -330,6 +330,8 @@ sub IsRTAddress {
     my $self = shift;
     my $address = shift;
 
+    return undef unless defined($address) and $address =~ /\S/;
+
     if ( my $address_re = RT->Config->Get('RTAddressRegexp') ) {
         return $address =~ /$address_re/i ? 1 : undef;
     }
diff --git a/t/api/emailparser.t b/t/api/emailparser.t
index 7903146..a58cb36 100644
--- a/t/api/emailparser.t
+++ b/t/api/emailparser.t
@@ -2,12 +2,14 @@
 use strict;
 use warnings;
 
-use RT::Test nodb => 1, tests => 10;
+use RT::Test tests => 11;
 
-RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
+ok(require RT::EmailParser);
 
+RT->Config->Set( RTAddressRegexp => undef );
+is(RT::EmailParser::IsRTAddress("",""),undef, "Empty emails from users don't match queues without email addresses" );
 
-ok(require RT::EmailParser);
+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