You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2009/08/28 18:05:28 UTC
svn commit: r808936 - in /spamassassin/trunk/lib/Mail/SpamAssassin:
PerMsgStatus.pm Plugin/Check.pm
Author: mmartinec
Date: Fri Aug 28 16:05:27 2009
New Revision: 808936
URL: http://svn.apache.org/viewvc?rev=808936&view=rev
Log:
Add option 'tflags' to sub got_hit(), simplifying life for
plugins which provide dynamic rules and scores.
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=808936&r1=808935&r2=808936&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Fri Aug 28 16:05:27 2009
@@ -2174,6 +2174,13 @@
C<hit_rule> plugin call, called by this method. If unset, I<'unknown'> is
used.
+=item tflags => $string
+
+Optional: a string, i.e. a space-separated list of additional tflags
+to be appended to an existing list of flags in $self->{conf}->{tflags},
+such as: "nice noautolearn multiple". No syntax checks are performed.
+
+
=item description => $string
Optional: a custom rule description string. This is used in the
@@ -2210,10 +2217,16 @@
my $value = $params{value};
if (!$value || $value <= 0) { $value = 1 }
- my $already_hit = $self->{tests_already_hit}->{$rule} || 0;
+ my $tflags_ref = $conf_ref->{tflags};
+ my $tflags_add = $params{tflags};
+ if (defined $tflags_add && $tflags_add ne '') {
+ $_ = (!defined $_ || $_ eq '') ? $tflags_add : ($_ . ' ' . $tflags_add)
+ for $tflags_ref->{$rule};
+ };
+ my $already_hit = $self->{tests_already_hit}->{$rule} || 0;
# don't count hits multiple times, unless 'tflags multiple' is on
- if ($already_hit && ($conf_ref->{tflags}->{$rule}||'') !~ /\bmultiple\b/) {
+ if ($already_hit && ($tflags_ref->{$rule}||'') !~ /\bmultiple\b/) {
return;
}
@@ -2224,6 +2237,7 @@
if ($dynamic_score_provided) { # copy it to static for proper reporting
$conf_ref->{scoreset}->[$_]->{$rule} = $score for (0..3);
+ $conf_ref->{scores}->{$rule} = $score;
}
my $rule_descr = $params{description};
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm?rev=808936&r1=808935&r2=808936&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm Fri Aug 28 16:05:27 2009
@@ -52,18 +52,14 @@
if (defined $suppl_attrib && ref $suppl_attrib->{rule_hits}) {
my @caller_rule_hits = @{$suppl_attrib->{rule_hits}};
dbg("check: adding caller rule hits, %d rules", scalar(@caller_rule_hits));
- my($tflags_ref) = $pms->{conf}->{tflags};
for my $caller_rule_hit (@caller_rule_hits) {
next if ref $caller_rule_hit ne 'HASH';
my($rulename, $area, $score, $value, $ruletype, $tflags, $description) =
@$caller_rule_hit{qw(rule area score value ruletype tflags descr)};
- if (defined $tflags) {
- $_ = join(' ', !defined $_ ? () : split(' '),
- split(/[ \t,]+/,$tflags)) for $tflags_ref->{$rulename};
- }
$pms->got_hit($rulename, $area,
!defined $score ? () : (score => $score),
!defined $value ? () : (value => $value),
+ !defined $tflags ? () : (tflags => $tflags),
!defined $description ? () : (description => $description),
ruletype => $ruletype);
}