[Rt-devel] [PATCH] Sync IsRTAddress() and CullRTAddresses() (WAS:
Why two IsRTAddress() and CullRTAddresses()?)
Petter Reinholdtsen
pere at hungry.com
Fri Jan 5 10:10:43 EST 2007
[Ruslan Zakirov]
> Check out 3.6.3RC2, there is some changes in these functions, but
> still we should get rid of all duplicates.
I saw no related changes to these functions there. Anyway, here is a
patch relative to the current svn to implement my suggestion, making
sure the functions in RT::Interface::Email uses RT::EmailParser, and
document that the former are obsolete.
I removed the code in RT::Interface::Email::IsRTAddress() to use '' if
no argument is missing, as this code isn't used as far as I can see.
If it still si needed, it could either be added there or in
RT::EmailParser::IsRTAddress().
Note, this patch is not tested in its current form.
Index: lib/RT/EmailParser.pm
===================================================================
--- lib/RT/EmailParser.pm (revision 6706)
+++ lib/RT/EmailParser.pm (working copy)
@@ -465,15 +465,10 @@
sub CullRTAddresses {
my $self = shift;
my @addresses= (@_);
- my @addrlist;
- foreach my $addr( @addresses ) {
- # We use the class instead of the instance
- # because sloppy code calls this method
- # without a $self
- push (@addrlist, $addr) unless RT::EmailParser->IsRTAddress($addr);
- }
- return (@addrlist);
+ # We use the class instead of the instance because sloppy code
+ # calls this method without a $self
+ return grep !RT::EmailParser->IsRTAddress($_), @addresses;
}
# }}}
Index: lib/RT/Interface/Email.pm
===================================================================
--- lib/RT/Interface/Email.pm (revision 6706)
+++ lib/RT/Interface/Email.pm (working copy)
@@ -191,20 +191,12 @@
Returns true if that address matches the $RTAddressRegexp.
Returns false, otherwise.
+This function is obsolete, use RT::EmailParser::IsRTAddress instead.
+
=cut
sub IsRTAddress {
- my $address = shift || '';
-
- # Example: the following rule would tell RT not to Cc
- # "tickets at noc.example.com"
- if ( defined($RT::RTAddressRegexp)
- && $address =~ /$RT::RTAddressRegexp/i )
- {
- return (1);
- } else {
- return (undef);
- }
+ return RT::EmailParser->IsRTAddress($address);
}
# }}}
@@ -216,10 +208,12 @@
Takes a single argument, an array of email addresses.
Returns the same array with any IsRTAddress()es weeded out.
+This function is obsolete, use RT::EmailParser::CullRTAddresses instead.
+
=cut
sub CullRTAddresses {
- return grep !IsRTAddress($_), @_;
+ return RT::EmailParser->CullRTAddresses(@_);
}
# }}}
Friendly,
--
Petter Reinholdtsen
More information about the Rt-devel
mailing list