Raj,
> I have a small script that parses Amavis logs with subject in them.
> The problem with Subject logging is that subject is printed as such
> delimited by ", but the exact characters can appear as subject with
> out any escaping. So it cannot be parsed reliably. Is it possible to
> (optionally) encode the subject with Base64 (or any other method) so
> that it is easy to parse by an external script.
When Subject is added to a mail log entry template ($log_templ), it is
common to use a macro dquote around it:
[? [:header_field|Subject]||, Subject: [:dquote|[:header_field|Subject|100]]]#
So existing double quotes are doubled, and the entire string is enclosed
in double quotes, e.g.
Subject: abc "def" ghi
is logged as:
Subject: "abc ""def"" ghi"
which allows for reliable parsing.
There is currently no macro to encode its argument to b64, although
this is an easy addition, allowing for:
[? [:header_field|Subject]||, Subject:
[:b64encode|[:header_field|Subject|100]]]#
Here is a patch to add the macro b64encode to 2.6.1:
--- amavisd.orig 2008-06-29 02:37:58.000000000 +0200
+++ amavisd 2008-09-22 18:54:17.000000000 +0200
@@ -8082,4 +8082,5 @@
use Digest::MD5;
use Net::Server 0.87; # need Net::Server::PreForkSimple::done
+use MIME::Base64;
use vars qw(
@@ -8483,4 +8484,5 @@
dquote => sub {my($nm)=shift; join('', map { s{"}{""}g; '"'.$_.'"' } @_)},
uquote => sub {my($nm)=shift; join('', map { s{[ \t]+}{_}g; $_ } @_)},
+ b64encode => sub {my($nm)=shift; join(' ', map {encode_base64($_,'')} @_)},
# macros f, T, C, B will be defined for each notification as appropriate
# (representing From:, To:, Cc:, and Bcc: respectively)
Mark
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
AMaViS-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/