svn commit: r1936171 - spamassassin/trunk/build
[email protected] Wed, 15 Jul 2026 19:32:04 -0000
| Newsgroups | gmane.mail.spam.spamassassin.cvs |
|---|---|
| Message-ID | <178414392447.2366087.16118775371513179942@svn03-he-fi> |
Author: fkento
Date: Wed Jul 15 19:32:04 2026
New Revision: 1936171
Log:
mkrules: recognize ifhandler as a conditional and load handlers for lint
Only 'if'/'ifplugin' were treated as conditional-openers, so an 'ifhandler'
line in a sandbox rule was dropped and its 'endif' orphaned -- desyncing
if/endif in the generated 72_active.cf and stripping the handler guard so the
handler's evals linted as 'unknown eval'.
- add 'ifhandler' to the conditional-opener regex
- handle 'ifhandler' in invert_conditional (inverts to if !plugin(...))
- load rules/v403.pre's handlers in the lint pretext, guarded by feature_handlers
Modified:
spamassassin/trunk/build/mkrules
Modified: spamassassin/trunk/build/mkrules
==============================================================================
--- spamassassin/trunk/build/mkrules Wed Jul 15 19:02:28 2026 (r1936170)
+++ spamassassin/trunk/build/mkrules Wed Jul 15 19:32:04 2026 (r1936171)
@@ -241,6 +241,17 @@ sub lint_rule_text {
loadplugin Mail::SpamAssassin::Plugin::URIDNSBL
util_rb_tld com # skip "need to run sa-update" warn
use_bayes 0
+
+ # Load the MIME-part handlers enabled in rules/v403.pre so that rules
+ # gated behind "ifhandler Mail::SpamAssassin::Handler::X" -- and the eval
+ # rules those handlers register -- lint cleanly. Guarded by feature_handlers
+ # so older code without handler support still lints.
+ if can(Mail::SpamAssassin::Conf::feature_handlers)
+ loadhandler Mail::SpamAssassin::Handler::HTML
+ loadhandler Mail::SpamAssassin::Handler::JavaScript
+ loadhandler Mail::SpamAssassin::Handler::SVG
+ loadhandler Mail::SpamAssassin::Handler::ICS
+ endif
};
my $mailsa = Mail::SpamAssassin->new({
@@ -561,7 +572,7 @@ sub rule_file_compile {
}
}
elsif (/^
- (if|ifplugin)
+ (if|ifplugin|ifhandler)
\s+(.*?)$
/x)
{
@@ -1193,6 +1204,10 @@ sub invert_conditional {
my $cond = shift;
if ($cond =~ /^ \s* ifplugin \s+(.*?)$ /x) {
return "if !plugin($1)\n";
+ } elsif ($cond =~ /^ \s* ifhandler \s+(.*?)$ /x) {
+ # a handler is a Plugin subclass, recorded in plugins_loaded, so it
+ # inverts through the plugin() conditional just like ifplugin
+ return "if !plugin($1)\n";
} elsif ($cond =~ /^ \s* if \s+(.*?)$ /x) {
return "if !($1)\n";
} else {