procmail
[Top] [All Lists]

Re: removing egroups ad

2000-09-04 15:28:14
Stan wrote,

| Without worrying about many other minor formatting changes they
| might make, the following should remove the ad, which I'm defining
| as the first "paragraph" whenever it mentions "click.egroups.com".
| (This is likely to be more general than the others posted since
| it doesn't depend on formatting details; however, it won't handle
| any ads-at-the-bottom saved old mails you might have)
| 
| Note, you should make sure that you can actually pass 500000-byte
| arguments to "echo"; if not, reduce this number below.  Mails too
| large will retain the ad (but that will be the least of your
| problems :-)

If we use sed instead of echo, LINEBUF is not a problem.  The only thing
that concerns me about this method of attack is that the ad could poten-
tionally include a blank line.

| LINEBUF=500000
| 
| :0
| * ^X-eGroups-Return: 
| * ^List-Unsubscribe:(_dot_)*-unsubscribe(_at_)egroups\(_dot_)com
| * $ < $LINEBUF
| { }
| 
| :0a

`a' is a risk there; I'm not sure what it will do after empty braces.  You
could have just put the contents of the next set of braces between the first
pair.

| { 
|     # remove first paragraph if contains "...click.egroups.com..."
|     :0bBfwi
|     * ^^(.+($))*(.+click\.egroups\.com.+($))(.+($))*($)\/(.*($))+
|     | echo "$MATCH"
| 
|     :0hHfwi
|     |formail -A "X-Ad-Removed: yes"

`H' without `B' is the default, and neither is meaningful if there are no
conditions.  Also, `i' is a risk there, because you want procmail to feed the
entire operation area to the command and you want to know if it didn't accept
all of it.

| }

But in any case, I'd say to use sed and avoid the LINEBUF problems:

 :0bBfw
 * ^^(.+$)*.*(click\.egroups\.com|eGroups Sponsor)
 | sed 1,/^$/d
# :0afwh  # optionally
# | formail -A "X-Ad-Removed: yes"


_______________________________________________
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>