[imapfilter-devel] Request for external "mask"

Lefteris Chatzibarbas lefcha at hellug.gr
Tue Nov 18 00:30:31 EET 2003


On Fri, Nov 14, 2003 at 04:17:24PM +0100, Per Westerlund wrote:
> Problem:
> 
> Sometimes the decision whether to move a message to the "log" folder or 
> to keep it and mark it as "important" cannot be made using only fixed 
> strings in your matching expressions. It is not enough even to be able 
> to use regular expressions, sometimes a more thorough parsing of the 
> content of a message is required.
> 
> Proposal:
> 
> For those occasions when you need better decision support tools, let us 
> be able to use an external program. Why not like this:
> 
> [mask] [or|and] [not] external <path-to-external-program> [header]
> 
> 'mask', 'or', 'and' and 'not' work as for all other filter entries. 
> IMAPFilter runs this filter entry by starting <path-to-external-program> 
> with no arguments, and connecting a pipe to it. Through this pipe is 
> then fed the body of the message (normally) or, if the optional argument 
> 'header' is supplied, the header and the body. The external program 
> signals success (condition fulfilled) by exit code 0, everything else 
> signals failure (condition not met).
> 
> Implementation note:
> 
> It is important that the filter entries use "short circuiting" so that 
> an external program placed last in the list is not queried if the total 
> condition has alerady failed.
> 
> A timeout for the external program should be implemented.
> 
> Watch out for SIGPIPE or similar problems it the external program exits 
> prematurely.

Yes, this feature would greatly extend imapfilter's capabilities and is
something I was considering during last summer (also suggested by some
in the past ("pipe" functionality)).

The problem is all the details about how this "special" pipe/external
mask would be treated in the context of all the other "regular" masks
that are basically send to server for evaluation (so imapfilter doesn't
worry about them right now).  Some of the questions/issues are:

  1) This "special" pipe/external mask can be put only once or even more
  times?

  2) Can it be placed among other masks or only last one before the
  "action" closing keyword (last condition to check on the all the
  messages that matched all other "regular" masks)?

  3) What about and/or/not logical operators and pipe/external masks?
  
  4) Can you use and/or/not logical operators both between "regular" and
  pipe/external masks or only between the same kind of masks?

  (Probably, other details, that do not come to my mind right now or
  that will come up, when the coding will begin... )

There is basically the problem of making this functionality powerful and
as useful as it gets for the users of imapfilter, without turning the
implementation a hack; the result should be clean and depending on some
of the answers on the questions above, it may get really complicated to
combine regular/remote and special/local masks.  Of course a simple
solution to a complicated problem is always desired and it is what we
are looking for...

Answers, suggestions, ideas, requests, objections, etc. on this, are
welcomed.





More information about the Imapfilter-devel mailing list