You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@bugzilla.spamassassin.org on 2007/02/21 14:33:25 UTC

[Bug 5345] New: address transformation to RE as a function (ENHANCEMENT)

http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5345

           Summary: address transformation to RE as a function (ENHANCEMENT)
           Product: Spamassassin
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: Libraries
        AssignedTo: dev@spamassassin.apache.org
        ReportedBy: raul@dias.com.br


Please note that this is not a BUG, but an ENHANCEMENT (in severity).

The right place for this is probably the dev- ml, but I am not subscribed there
anymore.

There is a code that transform an address used in [white|vlack]list_* rules that
is rewritten in 4 different places of SA:
Mail::SpamAssassin::Conf::Parser::add_to_addrlist() , 
Mail::SpamAssassin::Conf::Parser::add_to_addrlist_rcvd() ,
and twice on Mail::SpamAssassin::Plugin::WhiteListSubject

I have already used this code twice on my Plugins and probably will use more.

Transforming this into a function will prevent that any improvement to the RE is
not available to all parts that use it.

It will also facilitate plugin writters life to search/copy/paste it.  Specially
lazy ones that might start writting there on replacement code (without knowing
this even exists).

That said, here is a suggestion function for the parser:

sub address2re
{
  my ($self, $address) = @_;

  $address =~ s/[\000\\\(]/_/gs;               # paranoia
  $address =~ s/([^\*\?_a-zA-Z0-9])/\\$1/g;    # escape any possible metachars
  $address =~ tr/?/./;                         # "?" -> "."
  $address =~ s/\*+/\.\*/g;                    # "*" -> "any string"
  return "^${address}\$";
}



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.