[Mimedefang] documentation bug/omission for newbies

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Tue Apr 19 02:58:23 EDT 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 18 Apr 2016, starlight.2016q2 at binnacle.cx wrote:

> I just spent a day butting my head against the fact that filter_begin() 
> is _always_ passed a multipart MIME message container that _never_ has a 
> useable $entity->bodyhandle().  This is not mentioned *anywhere*.

hmm, I would not rely on this assumption.

> I'm still having trouble seeing it--apologies.  Spent most of an hour 
> going through the presentation deck Saturday while writing the body 
> regex scanner and did not find anything that addresses it.  Just looked 
> again searching the document for "body," "open," "text," "match" 
> "regex," "regular," "expression," "getline" and "match" with no luck.

Hmm,

because MIMEDefang internally breaks up the message into parts anyway and 
feeds all parts to filter(), I would construct your code like so:

filter_begin {

   $globalFlag = 0;

}

filter {

  if($globalFlag == 0) { # first plain part ever
    $globalFlag = 1;
    if($type =~ m!\Atext/!i) {
     scan that part
     if(condition) {
      $gloablFlag = 2; or drop/replace part right here and now
     }
    }
  }

}

filter_end {
   if($globalFlag == 2) {
     full message processing
   }
}

Of course, if you do no further processing, this looks like overhead.

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEVAwUBVxXXD1GgR0+MU/4GAQIFDAf/RxavIbAicmLftDwvQ2HVlf3rMO+zk3ph
62OkDAVzeiSMDEFnqHytwd9NAy90G1RPiCx6FZpRZqkM1Me2We7+LdBUhi6UsvjD
YRdCqJ4n1qLKQ48zqIY1jr1FgnwfkGTGh7cqbzSllORe9ONGXfKlszXs2VYeb9t8
5bsACDAyYcD+ZPPe0d+2CCHRMNiERRZK9JMOMQxfEmHZuykYdTDPFuO2sNZTVzec
94nDdt4lNRP3Sf6BGYO1S83ZWs7AFcBD4fB5p/M1JiuVGdPRM80BkMhpuPvBwZhY
xuB7e2r2jyoLb5VV8zMisabIyPW++TcocXBgqQloNxCRQe6yOQOZlg==
=65Va
-----END PGP SIGNATURE-----



More information about the MIMEDefang mailing list