procmail
[Top] [All Lists]

Re: Brock's size test

1999-12-24 13:29:57
David wrote, continuing the discussion begun by Brock: 

Does your version of head support a -b or -c option?  Head would work much
better than split, because it filters from stdin to stdout without creating
another file that has to be removed, and it will stop after the number of
bytes you want to save instead of going on to save more files that you won't
use at all.

So we could try something like this:
...
  # if we hit the limit somewhere in the body, cut there
  :0Efi
  | head -c $BKPSIZE
   :0A: # same comment about local lock
   $BKP
 }

There is, however, an obvious problem with this type of solution, and
that problem is probably more evident when dealing with large messages.

That problem is engendered by the increasing use of mime encodings
in mail (and no, I don't mean that I think use of mime is a problem,
in fact I welcome it). The problem occurs when you arbitrarily (with
respect to the mime structure) remove part of the message, leaving
something which may be unusable in the recipient's mailbox.

So, you have a choice here. You can
1) blindly truncate the message, and probably leave a partial mime part
   with perhaps one or more complete mime parts preceding it, but most
   likely no proper termination, or
2) attempt to do some mime processing, either within your procmail rc or
   externally, and pass on all or some of the text part(s), or
3) replace the whole message with a note to the user.
In any case, you should consider the need to disarm the mime headers at
the same time.

-- 
Rik Kabel          Old enough to be an adult              
rik(_at_)netcom(_dot_)com

<Prev in Thread] Current Thread [Next in Thread>