diff --git a/lib/RT/EmailParser.pm b/lib/RT/EmailParser.pm index 4cf4184a446dbb2060e53c4e9bb96cde4d115409..af4e396a5516de0c3eb8848351cf208cb2a0e502 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 7903146030474d2345e5a0f89eac9abebe80e03a..a58cb3623f3861e371cb020515adc8036204062f 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" );