This is a discussion on Re: [AMaViS-user] Subject Tag Templates with Macro Expansion within the Amavis User forums, part of the Anti-Spam and Anti-Virus Related Forums category; Joel Nimety wrote: > Joel Nimety wrote: >> Gary V wrote: >>> Joel wrote: >>> &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Joel Nimety wrote:
> Joel Nimety wrote: >> Gary V wrote: >>> Joel wrote: >>> >>>> In our environment it would be useful to allow subject tag customization >>>> much like the existing ability to customize notifications using >>>> templates (including macro expansion). We currently have a requirement >>>> to add the raw spamassassin score to the subject or a confidence score >>>> (as a percentage, using the kill_level as 100%). If you don't mind, >>>> please answer a few questions before I get started... >>>> 1) Is anyone else working on such a functionality? >>>> 2) Is there a helper function for the notification templates that I can >>>> use for macro expansion? >>>> 3) Is add_forwarding_header_edits_per_recip the proper place to modify >>>> the subject_tag? >>>> Your comments are much appreciated. >>> http://marc.theaimsgroup.com/?l=amav...7239616558&w=2 >> Thanks. I will use this patch as a starting point but I was going to >> implement something that could use the same/similar macro expansion as >> the notification templates. This way the subject_tag template could be >> defined on a per recipient basis using LDAP/SQL instead of harcoded in >> amavisd. > > Find attached a first attempt at providing macro expansion within the > subject tag. Patch is against 2.4.2. I've tested it with LDAP but it > should work with SQL and spam_subject_tag*_maps as well. Two macros have > been added (kill_level and percent_score) for use in the subject. > Comments, suggestions, and criticism are welcome. > This one was awaiting approval as well... Here is a new version that includes a new macro sprintf that allows formatting of a single variable using (none other than) Perl's builtin sprintf function. The sprintf macro takes two arguments, a string and an sprintf format string. Example: '[: sprintf | [: percent_score] | ["%2d"]]\%' yields something like 99% --- amavisd-new-2.4.2/amavisd 2006-06-27 07:31:56.000000000 -0400 +++ amavisd-new-2.4.2/amavisd 2006-07-12 14:38:53.000000000 -0400 @@ -6697,6 +6697,8 @@ if (!@rest) { $v++ } else { $v += $_ for @rest }; "$v"}, decr => sub {my($name,$v,@rest) = @_; if (!@rest) { $v-- } else { $v -= $_ for @rest }; "$v"}, + sprintf => sub {my($name,$s,$fmt) = @_; + sprintf($fmt, $s)}, # macros f, T, C, B will be defined for each notification as appropriate # (representing From:, To:, Cc:, and Bcc: respectively) # remaining free letters: xEGIJKLMPYZ @@ -8469,12 +8471,24 @@ } my($subject_insert); # concatenation of triggered subject tag strings if ($do_subj || $do_subj_u) { + my(%mybuiltins) = %builtins; # make a local copy + my($sl) = !defined($spam_level) ? 'x' + : 0+sprintf("%.3f",$spam_level); # trim fraction + $mybuiltins{'kill_level'} = lookup(0,$recip, @{ca('spam_kill_level_maps')}); + $mybuiltins{'percent_score'} = $sl eq 'x' ? 'x' + : $sl/$mybuiltins{'kill_level'}*100 > 100 ? 100 + : $sl/$mybuiltins{'kill_level'}*100; if ($do_subj_u) { $subject_insert = c('undecipherable_subject_tag'); + my($strr) = expand(\$subject_insert, \%mybuiltins); + $subject_insert = $$strr; # replace with macro expanded copy do_log(3,"adding %s, %s, %s", $subject_insert, $any_undecipherable, $hold); } - $subject_insert .= $subject_tag if $do_subj; + if ($do_subj){ + my($strr) = expand(\$subject_tag, \%mybuiltins); + $subject_insert .= $$strr; # append macro expanded copy + } } my($key) = join("\000", map {defined $_ ? $_ : ''} ( $do_tag_virus_checked, $do_tag_virus, $do_tag_banned, $do_tag_badh, -- Joel Nimety -- The sender of this email subscribes to Perimeter Internetworking's email anti-virus service. This email has been scanned for malicious code and is believed to be virus free. For more information on email security please visit: http://www.perimeterusa.com/maliciou...e_content.html This communication is confidential, intended only for the named recipient(s) above and may contain trade secrets or other information that is exempt from disclosure under applicable law. Any use, dissemination, distribution or copying of this communication by anyone other than the named recipient(s) is strictly prohibited. If you have received this communication in error, please delete the email and immediately notify our Command Center at 203-541-3444. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=...057&dat=121642 _______________________________________________ AMaViS-user mailing list AMaViS-user@lists.sourceforge.net https://lists.sourceforge.net/lists/...fo/amavis-user AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 AMaViS-HowTos:http://www.amavis.org/howto/ |
![]() |
| Thread Tools | |
| Display Modes | |
|
|