On Friday, Jun 6, 2003, at 01:20 Canada/Mountain, Frank Nørvig wrote:
This is a multi-part message in MIME format.
--Boundary_(ID_IxABGDJSadA14WV3ydHl9g)
Content-type: multipart/alternative;
boundary="Boundary_(ID_H93SlJqUwEslhhkIQEiSYw)"
This is a multi-part message in MIME format.
--Boundary_(ID_H93SlJqUwEslhhkIQEiSYw)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: quoted-printable
Hello,
Is it possible to extract part of a body, ex. only the "Content-Type: =
text/plain;" part?=20
I find it ironic that you posted a multi-part message asking how to
strip multi-part messages. :)
This is tricky to do in procmail. You need to get the content-boundary
from the headers, then search the body for the boundary. This is as
far as I got playing with it before I decided to go a different route
(simply disabling suspicious multi-part files by marking them as
text/plain in the headers:
#:0 cw # work on a copy of the message so we can compare the munged
version to the original.
# Extract the Boundary marker from the header.
* ^Content-type:[ ]multipart.*boundary="\/.*[^"]
{
BOUNDARY=$MATCH
# Delete the HTML portion of the message:
:0 bfw
* ^Content-type:(.*\<)?text/html
| sed -e "/Content-Type: text\/html;/,/$BOUNDARY/d"
:0 A
{
:0 bfw
| sed -e "/$BOUNDARY/,/Transfer-Encoding/d"
:0 fw
| formail -i"Content-Type: text/plain" \
-i"X-HTML: Altered text/html to text/plain"
:0 fw
* B ?? This is a multipart message in MIME format
| sed -e "/This is a multipart message in MIME format/d"
}
}
Now, this recipe was never completed, but it might give you a place to
start. If you drop it in a production rc file and lose email don't
whine to me.
Can it be done with formail?
No.
I've tried but I always end up with the complete body including
attached =
files, which isn't good since it's for a virus-filter.
There are better ways to defang potential virus attachments. Check the
list archive for the last month for Sean's posts, for one.
--
Eyes the shady night has shut/Cannot see the record cut
And silence sounds no worse than cheers/After earth has stopped the
ears.
--
I know that you believe you understand what you think I said but I am
not sure you realize that what you heard is not what I meant.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail