Skip to content
Snippets Groups Projects
Commit 65127b33 authored by Alex Vandiver's avatar Alex Vandiver
Browse files

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.
parent 8eea66ea
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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" );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment