[Mimedefang] Folding headers?

John Nemeth jnemeth at victoria.tc.ca
Mon Feb 7 22:40:08 EST 2005


On Jun 19,  4:43am, "Damrose, Mark" wrote:
}
} I suspect (but can't prove) that very long headers in some messages
} contributing.
} I've changed my filter to add headers to all messages that are scanned by
} SpamAssassin, but not blocked as spam.
} 
}         action_change_header("X-Spam-Score", "$hits");
}         action_change_header("X-Spam-Matches", "$names");
}         action_change_header("X-Spam-Setting", "$req");
} 
} I suspect that the "X-Spam-Matches" header is getting too long when many low
} value tests match, but it doesn't reach our threshold to block (8).
} I am running v2.41 - planning to upgrade soon.
} 
} My questions.
} 
} Can MimeDefang automatically fold long headers?  

     No.

} Follow up question, If I have to fold the headers myself, will
} action_add_header
} or action_change_header change the standard \n end of line into an RFC 
} compliant <CR><LF>, or do I need to explicitly insert them?

     I use this:

use Text::Wrap ();

sub wrap_header ($$) {
    my ($hdr_name, $hdr_data) = @_;

    my $hdr = "$hdr_name!!$hdr_data";
    # use '!!' instead of ': ' so it doesn't wrap on the space
    $Text::Wrap::columns = 79;
    $Text::Wrap::huge = 'wrap';
    $Text::Wrap::break = '(?<=[\s,])';
    $hdr = Text::Wrap::wrap('', "\t", $hdr);
    return (split (/!!/, $hdr, 2))[1]; # just return the data part
}

You call it like this:

$status_header = wrap_header("X-Spam_Status",
    ($hits < $req ? "No, " : "Yes, ") .
    "hits=$hits required=$req tests=$names autolearn=$learn " .
    "version=" . Mail::SpamAssassin::Version() );

I basically swiped this from SpamAssassin.  You can learn all sorts
of things by looking at the SpamAssassin source code.

}-- End of excerpt from "Damrose, Mark"



More information about the MIMEDefang mailing list