You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Justin Mason <jm...@jmason.org> on 2004/09/30 18:50:20 UTC

Re: [Bug 3848] SA 3.0 time outs with amavis+razor

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Bob Apthorpe writes:
> That should gracefully handle both SA 2.x and 3.x, correct?

actually, it looks like we totally dropped the
Mail::SpamAssassin::NoMailAudit module entirely.   When we were doing
this, I suggested we leave a vestigial, empty module for that in 3.0.0 to
avoid this problem, just so that the "use" line could still be used, but
looks like I got outvoted :(   So the code has to be more complex,
unfortunately.

I've also fixed a couple of buglets (use parse(), not M:SA:Message
constructor, and keep the $spamtest object around).

- --j.



At the head of the module where all the 'use' statements live...
- ----
  use Mail::SpamAssassin;

  use Mail::Header;
  use Mail::Internet;

  if ($Mail::SpamAssassin::VERSION < 3) {
      eval { require Mail::SpamAssassin::NoMailAudit; };
  } else {
      eval { require Mail::SpamAssassin::Message; };
  }
- ----

Then later, once we've wrapped the text in fake mail headers to make
a RFC822-compliant message...
- ----
    # Make a M::SA object; point to custom configs
    my $spamtest = Mail::SpamAssassin->new($self->{'sa_prefs'});

    my $message =
      Mail::Internet->new('Header' => $mailhead, 'Body' => $Rl_body);

    # Fake up a mail message and stuff the comment in the body
    if ($Mail::SpamAssassin::VERSION < 3) {
        $self->{'_mail'} =
          eval { Mail::SpamAssassin::NoMailAudit->new('data' =>
[$message->as_string]); };
    } else {
        $self->{'_mail'} =
          eval { $spamtest->parse ([$message->as_string]); };
    }
- ----

And finally, analyze the message...
- ----
    # Get verdict, score, list of rules
    my $status = $spamtest->check($self->{'_mail'});
- ----


- --j.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Exmh CVS

iD8DBQFBXDlMQTcbUG5Y7woRAiu/AKDrIzh/VRDCHZgrR8i0iXZuDxtffACdF6dU
mC7Qs3rk1L8G6/reSp3wDd0=
=5a9M
-----END PGP SIGNATURE-----


Re: [Bug 3848] SA 3.0 time outs with amavis+razor

Posted by "Malte S. Stretz" <ms...@gmx.net>.
On Thursday 30 September 2004 18:50 CET Justin Mason wrote:
> Bob Apthorpe writes:
> > That should gracefully handle both SA 2.x and 3.x, correct?
>
> actually, it looks like we totally dropped the
> Mail::SpamAssassin::NoMailAudit module entirely.   When we were doing
> this, I suggested we leave a vestigial, empty module for that in 3.0.0 to
> avoid this problem, just so that the "use" line could still be used, but
> looks like I got outvoted :(   So the code has to be more complex,
> unfortunately.

I can just judge from the snippet below, but...

> At the head of the module where all the 'use' statements live...
> ----
>   use Mail::SpamAssassin;
>
>   use Mail::Header;
>   use Mail::Internet;
>
>   if ($Mail::SpamAssassin::VERSION < 3) {
>       eval { require Mail::SpamAssassin::NoMailAudit; };
>   } else {
>       eval { require Mail::SpamAssassin::Message; };
>   }
> ----

This should be enough:
----
  use Mail::SpamAssassin;

  use Mail::Header;
  use Mail::Internet;

  if ($Mail::SpamAssassin::VERSION < 3) {
      require Mail::SpamAssassin::NoMailAudit;
  }
----
Because Mail::SpamAssassin v3 already use()s ::Message so it's also 
available for the calling code.  And wrapping the stuff into eval()s 
doesn't make sense because require() (in contrast to use()) is scoped so if 
the block isn't reached, nothing will try to include ::NoMailAudit.

> Then later, once we've wrapped the text in fake mail headers to make
> a RFC822-compliant message...
> ----
>     # Make a M::SA object; point to custom configs
>     my $spamtest = Mail::SpamAssassin->new($self->{'sa_prefs'});
>
>     my $message =
>       Mail::Internet->new('Header' => $mailhead, 'Body' => $Rl_body);
>
>     # Fake up a mail message and stuff the comment in the body
>     if ($Mail::SpamAssassin::VERSION < 3) {
>         $self->{'_mail'} =
>           eval { Mail::SpamAssassin::NoMailAudit->new('data' =>
> [$message->as_string]); };
>     } else {
>         $self->{'_mail'} =
>           eval { $spamtest->parse ([$message->as_string]); };
>     }
> ----

The eval()s aren't needed here either.

>[...]

Cheers,
Malte

-- 
[SGT] Simon G. Tatham: "How to Report Bugs Effectively"
      <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
[ESR] Eric S. Raymond: "How To Ask Questions The Smart Way"
      <http://www.catb.org/~esr/faqs/smart-questions.html>