[Rt-commit] rt branch, 4.0/emailparser-false-positives, updated. rt-4.0.3-19-g9eb4830
Jason May
jasonmay at bestpractical.com
Mon Dec 5 15:55:46 EST 2011
The branch, 4.0/emailparser-false-positives has been updated
via 9eb483063fc8780381058cf307909ee13cf0b3a5 (commit)
via f721f586d0c51150ba9615233833797f48ddfe82 (commit)
from e50515e9291ebc57524bac135fbe0f4291248774 (commit)
Summary of changes:
lib/RT/EmailParser.pm | 2 +-
t/api/emailparser.t | 16 ++++++++--------
2 files changed, 9 insertions(+), 9 deletions(-)
- Log -----------------------------------------------------------------
commit f721f586d0c51150ba9615233833797f48ddfe82
Author: Jason May <jasonmay at bestpractical.com>
Date: Mon Dec 5 15:40:19 2011 -0500
Improve the test description for blank emails with EmailParser
User email addresses are not checked in the function; a user's email
address is passed in. Therefore there is no need to make a test user.
The "" email value is checked against email addresses assigned by
queues, and General has a blank email address by default.
diff --git a/t/api/emailparser.t b/t/api/emailparser.t
index bc81e7c..a58cb36 100644
--- a/t/api/emailparser.t
+++ b/t/api/emailparser.t
@@ -4,16 +4,10 @@ use warnings;
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" );
+is(RT::EmailParser::IsRTAddress("",""),undef, "Empty emails from users don't match queues without email addresses" );
RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
commit 9eb483063fc8780381058cf307909ee13cf0b3a5
Author: Jason May <jasonmay at bestpractical.com>
Date: Mon Dec 5 15:44:44 2011 -0500
Check that we have a non-word character in the email address.
diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm
index d2c84de..e1b5d6b 100644
--- a/lib/RT/EmailParser.pm
+++ b/lib/RT/EmailParser.pm
@@ -342,7 +342,7 @@ sub IsRTAddress {
return 1 if lc $comment_address eq lc $address;
}
- return undef unless length($address);
+ return undef unless length($address) and $address =~ /\W/;
my $queue = RT::Queue->new( RT->SystemUser );
$queue->LoadByCols( CorrespondAddress => $address );
diff --git a/t/api/emailparser.t b/t/api/emailparser.t
index a58cb36..bab1faa 100644
--- a/t/api/emailparser.t
+++ b/t/api/emailparser.t
@@ -2,13 +2,19 @@
use strict;
use warnings;
-use RT::Test tests => 11;
+use RT::Test tests => 12;
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" );
+my $queue = RT::Queue->new($RT::SystemUser);
+$queue->Load('General');
+$queue->SetCorrespondAddress('rtexamplecom');
+is(RT::EmailParser::IsRTAddress("","rtexamplecom"),undef, 'Emails without @ or . are seen as invalid' );
+$queue->SetCorrespondAddress("");
+
RT->Config->Set( RTAddressRegexp => qr/^rt\@example.com$/i );
is(RT::EmailParser::IsRTAddress("","rt\@example.com"),1, "Regexp matched rt address" );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list