procmail
[Top] [All Lists]

Re: How to avoid s/\n/ /g when unfolding a header

2004-12-13 05:18:33
On Sun, 12 Dec 2004, 20:18 GMT+01 Robert Allerstorfer wrote:

This should "clean" a
subject header like (real life example!)

Subject: =?utf-8?q?Today Show - Rolex o?=
 =?utf-8?q?r Cartier or Breitl?=
 =?utf-8?q?ing?=

to

Subject: Today Show - Rolex or Cartier or Breitling

Removing the extra spaces originating from newlines would then give

Subject: Today Show - Rolex o r Cartier or Breitl ing

with still unwanted spaces in it (from the beginning of each new
line). I hope to be able to do this also in pure procmail code.

OK, I think it is not possible to remove leading whitespace from each
line of a multiline string with pure procmail code. Therefore, I will
most likely use sed, like this:

av_SUBJECT = `formail -zx subject | sed -e 's/^[       ]*//'`

(having a SPACE and TAB within the []). A subject like

Subject: =?utf-8?q?First-line-followed-by-one-space?=
 Second-line

will result to

Assigning "av_SUBJECT2==?utf-8?q?First-line-followed-by-one-space?=
Second-line"

The next step is to delete all \n. Can this also done with sed?

Thanks,
rob.


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail