procmail
[Top] [All Lists]

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

2004-12-12 12:40:16
On Sun, 12 Dec 2004, 18:27 GMT+01 Dallman Ross wrote:

[...]

 :0
 * $ MATCH ?? $SPACE$SPACE
 { H_SUBJ = `formail -zx Subject | tr -d '\012'` }

[...]

Thank you Dallman, `formail -zx Subject` was the key to extract the
Subject without adding extra space.

H_SUBJ = `formail -zx Subject`
resulted in
Assigning "H_SUBJ==?utf-8?q?First-line-followed-by-one-space?=
 Second-line"

I will probably use it this way and then remove the newlines from
$H_SUBJ with pure procmail code.

If the situation is only important to Robert's application for
base65-encoded or quoted-printable Subject lines, then we could
further reduce the likelihood of needing the piped action in the
second recipe, with something like:

 :0
 *   MATCH ?? ^^?utf-8[?][bq][?]
 * $ MATCH ?? $SPACE$SPACE
 { H_SUBJ = `formail -zx Subject | tr -d '\012'` }

yes, I am using it to "deobfuscate" BQ encoded subjets, for easier
spam checking, like this:

 :0
  * $ ^subject:[$WS]+\/.+
  {
     av_SUBJECT = $MATCH
     INCLUDERC = $av_INSTALLDIR/inc/av_bq-subj.inc
  }

(making the checks within the sub routine). 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

When the subject would have remained unchanged after its extraction by
procmail, that would result in

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

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.

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