[Mimedefang] mimedefang vs. message/rfc822 attachments

Bryan Stansell bryan at stansell.org
Tue Jan 6 17:21:45 EST 2004


back on 2002-02-25 David added

    * mimedefang.pl.in (rebuild_entity): Work around bug in MIME::Tools
    which fails to rebuild message of type "message/rfc822"

to the ChangeLog.  it's still in mimedefang.pl (line 498)

        # Sigh... bug in MIME-Tools
        if (!($type =~ m{^multipart/})) {
            $type = "multipart/mixed";
        }

at least, i'm assuming that's the code that goes with the ChangeLog
entry...and what i'm basing the rest of this on.

i get quite a few email messages that have message/rfc822 attachments,
and i've noticed that when they're "defanged" (for whatever reason -
virus, bad html parts, etc) the part is converted to multipart/mixed
and, worst of all, the header information is dropped.  sometimes the
header lines are interesting or necessary for analysis...

my first question is, is this on purpose?  is the philosophy of
mimedefang to strip the header information and only pass on what it puts
in?  or, is this just a side-effect of the code?

so, i've been experimenting with a different approach and wondering if
i'm doing something horrible.  below the workaround above are the lines:

        my($subentity) = MIME::Entity->build(Type => $type,
                                             Disposition => $disposition);

i've replaced both the workaround and the line above with:

	my($subentity) = $in->dup;
	$subentity->parts([]);  # delete all parts

which, i believe, duplicates the multipart (rfc822 or otherwise) entity
and removes it's sub-parts, making a duplicate of the header info as
well as the content-type.  in my "test" world, the message/rfc822
attachments stay as that type and include all the header info.

so, to my eyes, it looks like it's avoiding the problems with
MIME::Tools and retaining the info i need.  does it fit with the
philosophy of mimedefang?  am i totally off-base here and doing
something wrong?  or is this a decent solution to my problem?

aside from this, mimedefang has been FANTASTIC.  it's flexibility and
hooks into other tools have made me sleep better at night.  thank you
very much!!!

Bryan



More information about the MIMEDefang mailing list