[Mimedefang] filter_final patch

Rudolph Pereira r.pereira at isu.usyd.edu.au
Mon Oct 6 21:55:01 EDT 2003


Hello,
I'm not sure how applicable my filtering/modification requirements are
to most people, but after trying a few different paths, I ended up
patching mimedefang.pl to call a final filtering function, after filter
end, that is called/callable instead of all the normal md
post-processing code. The reason for this is that in certain
circumstances (when the filter functions have judged that the mail
should be "defanged"), I need to replace the entire body of the mail
with the defanged version, where that version is _not_ a valid
mime::entity (basically, a specially-encoded plain text version of the
body).
Anyways, I've attached the patch (against 2.37) to this mail. Briefly, the
filter_function is called after filter_end (and only if defined). If it
returns false, the normal md post-processing occurs, otherwise that is
skipped and filter_function is assumed to have done all post-processing
of the mail, including calling the signal_* functions to notify the C
code.
Any feedback appreciated.

Thanks
-------------- next part --------------
--- mimedefang.pl.in.orig	2003-10-07 11:44:12.000000000 +1000
+++ mimedefang.pl.in	2003-10-07 11:45:06.000000000 +1000
@@ -45,7 +45,7 @@
 	    $MaxMIMEParts $InMessageContext $InFilterContext $PrivateMyHostName
 	    $EnumerateRecipients $InFilterEnd $FilterEndReplacementEntity
 	    $AddApparentlyToForSpamAssassin $WarningCounter
-	    %SendmailMacros %RecipientMailers $CachedTimezone);
+	    %SendmailMacros %RecipientMailers $CachedTimezone $Finished);
 
 use vars qw($GeneralWarning);
 use vars qw($HTMLFoundEndBody $HTMLBoilerplate $SASpamTester);
@@ -4407,6 +4407,7 @@
     $VirusName = "";
     $WasMultiPart = 0;
     $WarningCounter = 0;
+    $Finished = 0;
     undef %Actions;
     undef %SendmailMacros;
     undef %RecipientMailers;
@@ -4702,6 +4703,14 @@
 	undef $FilterEndReplacementEntity;
     }
 
+    # Call final processing function
+    if (defined(&filter_final))
+    {
+	$Finished=filter_final($rebuilt);
+    }
+
+    if(!$Finished)
+    {
     if ($Changed || $Rebuild) {
 	if (!open(OUT, ">NEWBODY")) {
 	    fatal("$MsgID: Can't open NEWBODY: $!");
@@ -4742,6 +4751,7 @@
     } else {
 	signal_unchanged();
     }
+    }
 
     signal_complete();
 


More information about the MIMEDefang mailing list