http://bugzilla.spamassassin.org/show_bug.cgi?id=3116
Summary: Allow custom eval tests
Product: Spamassassin
Version: unspecified
Platform: Other
OS/Version: other
Status: NEW
Severity: normal
Priority: P5
Component: Rules (Eval Tests)
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]
There are some cases where the standard SA tests just aren't enough. For
this, I propose extending EvalTests to allow for such custom tests. The
syntax I'm using is:
body <rule> eval:custom_body('<perl script>', '<function>', '<arg>')
For example:
body E_CHECKIT eval:custom_body
('/etc/mail/spamassassin/custom_checkit.pl', 'checkit', 'blah')
This only required a pretty simple change to EvalTests.pm (2.63):
+my %CUSTOM_FILES = ();
+
+sub custom_body{
+ my $self = shift;
+ my $full = shift;
+ my $file = shift;
+ my $func = shift;
+
+ if( !defined( $CUSTOM_FILES{ $file } ) ){
+ $CUSTOM_FILES{$file} = $file;
+ do $file;
+ }
+
+ {
+ no strict;
+ return *{$func}->($self, $full, shift, shift);
+ }
+}
The format of each custom file is like:
use strict
sub checkit{
my ($self, $fulltext, $type, $re ) = @_;
my $test = 0;
## test on messages here - see EvalTests.pm for ideas.
return $passed;
}
There are obviously some minor issues with the implementation, namely there's
nothing to prevent namespace conflicts on function names.
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.