procmail
[Top] [All Lists]

Re: Something like ereg_replace?

2003-07-05 23:19:54

Everything Sean said is true, and should be taken as gospel.

That said...

On Sat, Jul 05, 2003 at 02:08:57PM -0700, Bj?rn Lilja wrote:

The actual ereg for filtering a html-tag with attributes etc I do not
worry about if there was a function like ereg_replace. Basically I could
just filter everything within the < > tags, right...? I do not want to
change the content of the e-mail, just pre parse it in to a variable so
I can do more accurate filtering.

I'll assume you really mean this...

In say perl or php this would
definitely not be a problem and I take it that the eregs work the same?

The eregs work almost exactly the same.  But that's not what you're
talking about.  You're talking about a function named ereg_replace that
USES eregs.  You use eregs in procmail.  There are no functions.

Ok, so there is basically no ereg/replace function within the procmail
functionality then?

Since there are no functions, there are no ereg/replace functions.

But your suggested solution is certainly an option!
Could anyone give just a brief example on how this would be done I'm
sure I could work out the rest.

As long as you don't exceed buffers (configuration of which will be left
as an exercise for the reader), you could conceivably do something like:

  MSGBODY=`sed 's/<[^>]*>//g'`

  :0
  * MSGBODY ?? debt.free
  * MSGBODY ?? extra.money
  * MSGBODY ?? learn.more
  * MSGBODY ?? cash
  * MSGBODY ?? refund
  action

or

  :0
  * MSGBODY ?? penile
  * MSGBODY ?? pills
  * MSGBODY ?? confidential
  action

Personally, I'd be happier looking for "<[^ >@:/-][^ >@:-]{10,}>":

  Z="[^ >@:-]"
  :0
  * -10^0
  * 1^1 $ B ?? ()<[^ >@:/-]${Z}${Z}${Z}${Z}${Z}${Z}${Z}${Z}${Z}${Z}+>
  action

This still gets lots of positives though, notably inside BASE64-encoded
attachments, headers, C source code and configuration examples that put
<your_option_here>.

If you develop it into something useful, please let the list know.

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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