procmail
[Top] [All Lists]

line-by-line processing (was: Filtering out unwanted mime attachments)

1997-10-18 06:50:33
Edward J. Sabol writes on 16 October 1997 at 16:49:01
Excerpts from mail: (16-Oct-97) Re: Filtering out unwanted mime attachments by 
J Daniel Smith
This line-by-line parsing could be useful...the only problem I had was
with blank lines.  I couldn't get the reg-exp modified right, so I
used scoring to fix things up; there's probalby a better way.

I'm not sure what could be causing this problem with blank lines. Are we
talking blank lines at the end of the body or blank lines interspersed
thoughout the body? Are you using 3.11pre5 or higher? I believe that, prior

blank lines in the body.  MATCH seems to strip all leading blank lines
in some way...or maybe just the regexp needs refinement.  I'm using
3.11pre7, so that shouldn't be the problem.

Thusfar, the only way I've found to make this work is to deal with
four seperate cases as follows
-----
text1="

3. two blank lines above"

text2="
2. blank line above"

text3="1. line 1

3. blank line above"

text4="1. line 1
2. line 2
3. line 3"


text=$text3
:0
* text ?? ^^$\/$(.*$)+
{
  foo="blank line, blank line"
  rest="
$MATCH"
}
:E
* text ?? ^^$\/(.*$)+
{ foo="blank line, text line" }
:E
* text ?? ^^(.*$)\/$(.*$)+
{
  foo="text line, blank line"
  rest="
$MATCH"
}
:E
* text ?? ^^(.*$)\/(.*$)+
{ foo="text line, text line" }
:E
{ foo="who knows" }

rest=${rest:-$MATCH}
-----

Note that in the cases where there is a blank line after \/ I've
manually put it back in.

   Dan
------------------- message is author's opinion only ------------------
J. Daniel Smith <DanS(_at_)bristol(_dot_)com>        
http://www.bristol.com/~DanS
Bristol Technology B.V.                   +31 33 450 50 50, ...51 (FAX)
Amersfoort, The Netherlands               {info,jobs}(_at_)bristol(_dot_)co
m