[Rt-commit] rt branch, 4.0-trunk, updated. rt-4.0.22-8-geaaf32d

Wallace Reis wreis at bestpractical.com
Thu Sep 25 12:40:37 EDT 2014


The branch, 4.0-trunk has been updated
       via  eaaf32d119efb5f3840f5d4dcc486e2ba9fe5109 (commit)
       via  991c172f82a8e064fcb9e3a4ce1ecfbc91391a8a (commit)
      from  c6eacb20a533386d562e35109df22c6e0712fe4d (commit)

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

- Log -----------------------------------------------------------------
commit 991c172f82a8e064fcb9e3a4ce1ecfbc91391a8a
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.
    
    Fixes #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" );

commit eaaf32d119efb5f3840f5d4dcc486e2ba9fe5109
Merge: c6eacb2 991c172
Author: Wallace Reis <wreis at bestpractical.com>
Date:   Thu Sep 25 13:40:08 2014 -0300

    Merge branch '4.0/emailparser-false-positives' into 4.0-trunk


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


More information about the rt-commit mailing list