You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/07/30 17:36:14 UTC
svn commit: r561013 - in /spamassassin/trunk: build/mkupdates/listpromotable
lib/Mail/SpamAssassin/Conf/Parser.pm
Author: jm
Date: Mon Jul 30 08:36:13 2007
New Revision: 561013
URL: http://svn.apache.org/viewvc?view=rev&rev=561013
Log:
bug 5545: allow 'tflags publish' to be made default/non-default on a per-file basis for sandbox rules files, using a '#testrules' comment
Modified:
spamassassin/trunk/build/mkupdates/listpromotable
spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
Modified: spamassassin/trunk/build/mkupdates/listpromotable
URL: http://svn.apache.org/viewvc/spamassassin/trunk/build/mkupdates/listpromotable?view=diff&rev=561013&r1=561012&r2=561013
==============================================================================
--- spamassassin/trunk/build/mkupdates/listpromotable (original)
+++ spamassassin/trunk/build/mkupdates/listpromotable Mon Jul 30 08:36:13 2007
@@ -194,6 +194,11 @@
}
}
+ # rule was from a file marked with "#testrules" (bug 5545)
+ # note: this is after "tflags publish" support, so you can override
+ # it on a rule-by-rule basis anyway
+ next if ($mailsa->{conf}->{testrules}->{$name});
+
# ignore rules that are not marked as promotable
next unless ($obj->{promo});
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm?view=diff&rev=561013&r1=561012&r2=561013
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm Mon Jul 30 08:36:13 2007
@@ -240,10 +240,19 @@
my @conf_lines = split (/\n/, $_[1]);
my $line;
$self->{if_stack} = \@if_stack;
+ $self->{file_scoped_attrs} = { };
+
+ my $keepmetadata = $conf->{main}->{keep_config_parsing_metadata};
while (defined ($line = shift @conf_lines)) {
local ($1); # bug 3838: prevent random taint flagging of $1
+ # bug 5545: used to support testing rules in the ruleqa system
+ if ($keepmetadata && $line =~ /^\#testrules/) {
+ $self->{file_scoped_attrs}->{testrules}++;
+ next;
+ }
+
$line =~ s/(?<!\\)#.*$//; # remove comments
$line =~ s/\\#/#/g; # hash chars are escaped, so unescape them
$line =~ s/^\s+//; # remove leading whitespace
@@ -274,6 +283,8 @@
}
if ($value =~ /^end\s/) {
+ $self->{file_scoped_attrs} = { };
+
if (scalar @if_stack > 0) {
my $cond = pop @if_stack;
@@ -1049,8 +1060,12 @@
$conf->{priority}->{$name} ||= 0;
$conf->{source_file}->{$name} = $self->{currentfile};
- if ($self->{main}->{keep_config_parsing_metadata}) {
+ if ($conf->{main}->{keep_config_parsing_metadata}) {
$conf->{if_stack}->{$name} = $self->get_if_stack_as_string();
+
+ if ($self->{file_scoped_attrs}->{testrules}) {
+ $conf->{testrules}->{$name} = 1; # used in build/mkupdates/listpromotable
+ }
}
if ($self->{scoresonly}) {