[Mimedefang] Header wrapping revisited

Nels Lindquist nlindq at maei.ca
Thu Feb 21 14:07:21 EST 2002


Hi there.

I've been taking a look at implementing some sort of header wrapping 
in the add_header function for extremely long headers.

I'm curious as to the process whereby the altered message gets 
reassembled.

It appears that this is done in mimedefang.c, which reads in 
NEWHEADERS and calls smfi_addheader().  Is this assumption accurate?

According to the milter API docs, "Neither the name nor the value of 
the header is checked for standards compliance. 
[....]
If longer headers are needed, make them multiline. It is the filter 
writer's responsibility to ensure that no standards are violated."

The inference I'm making is that the header formatting should be done 
prior to the message reassembly; ie, a properly formatted header 
generated by mimedefang.pl will carry through to the milter message 
reassembly.

I've been trying to use the Mail::Header library for this, but I've 
run into some difficulties.

I've modified action_add_header as follows:

sub action_add_header {
    use Mail::Header ();

    my($header, $value) = @_;
    my $headers = new Mail::Header (Modify => 1, FoldLength => 65);
    $headers->add($header, $value);
    unless (open(HDRS, ">>NEWHEADERS")) {
        syslog('err', "Could not open NEWHEADERS to add headers: 
$!");
        return;
    }
    $headers->print (\*HDRS);
    close(HDRS);
}

Launching mimedefang with "-d", messages are left in the working 
directory, and I end up with NEWHEADERS files like this:

X-Spam-Status: Yes, hits=25.58 required=5 tests=X_PRIORITY_H
    IGH,FAKED_UNDISC_RECIPS,INVALID_MSGID,MSGID_HAS_NO_AT,EXCUSE
    _3,COPY_DVDS,MAILTO_LINK,A_HREF_TO_REMOVE,MAILTO_TO_REMOVE,F
    REQ_SPAM_PHRASE,SPAM_PHRASES_020,RCVD_IN_OSIRUSOFT_COM,RCVD_
    IN_RFCI,ROUND_THE_WORLD,X_OSIRU_SPAM_SRC

Leaving aside the poor job of RFC compliance it's doing (break at 
commas, anyone?), none of the line breaks are carried through to the 
final message.  Obviously this is the wrong approach.

Any suggestions would be gratefully appreciated!
----
Nels Lindquist <*>
Information Systems Manager
Morningstar Air Express Inc.




More information about the MIMEDefang mailing list