Steve Vertigan writes:
 > I'm thinking of writing a perl script to be called from a .qmail file
 > that will check a message for html encoding and kill it if it does.
 > Partly because I'm sick of seeing html on lists and partly because it
 > seems like a good bozo filter.  So anyway before I do pick up my hammer
 > and chisel I'm wondering has anyone else here already carved a rock into
 > a circumvolution mechanism that does something similiar?

This works for me.  I insert it into my .qmail file just before the
"./Mailbox".  It forwards the text part to nelson-alternative, which
just has "./Mailbox" in it.

#!/usr/bin/perl

#Content-Type: multipart/alternative;
#       boundary="----=_NextPart_000_0076_01BDFB89.721C71C0"

while(<>) {
  $continuation = 0 if /^\S/;
  $continuation = 1 if m!^Content-Type: multipart/alternative;!i;
  $boundary = $1 if $continuation && /boundary="(.*?)"/;
  last if /^$/;
  $headers .= $_ unless $continuation;
}

# dispose of messages which are not multipart/alternative
unless ($boundary) {
  exit 0;
}

$boundary =~ s/\W/\\$&/g;
$printing = 0;                  # we start by discarding the pre-message cuft.
$header = 0;                    # and we start outside of a header.
open(MAIL, "|forward $ENV{USER}-alternative") or die;
print MAIL $headers;
while(<>) {
  last if /^--$boundary--$/;
  if (/^--$boundary$/) {
    $header = 1;
    $printing = 0;
    next; # discard boundary
  }
  $printing = 0 if $header && m!^Content-Type:!i;
  $printing = 1 if $header && m!^Content-Type: text/plain;?!i;
  $header = 0 if $header and /^$/;
  print MAIL if $printing;
}
close MAIL;

exit 99;

-- 
-russ nelson <[EMAIL PROTECTED]>  http://russnelson.com
Crynwr sells support for free software  | PGPok | Government schools are so
521 Pleasant Valley Rd. | +1 315 268 1925 voice | bad that any rank amateur
Potsdam, NY 13676-3213  | +1 315 268 9201 FAX   | can outdo them. Homeschool!

Reply via email to