procmail
[Top] [All Lists]

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

2004-12-12 09:33:14
Robert Allerstorfer wrote:

For example, the original Subject header may look like this:

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

Please note that there is only one space character in it. When I let
procmail do

 :0
  * $ ^subject:[$WS]+\/.+
  {
     av_SUBJECT = $MATCH
  }

where $WS holds the SPACE and TAB character, this results in

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

Now the unfolded Subject got an additional space at the place the
newline was. How can I avoid replacing all these newlines by a space?

I'd say punt.

  :0
   * $ ^subject:[$WS]+\/.+
   {
      av_SUBJECT = `echo "$MATCH" | sed 's/  */ /g'`
   }

[can't remember the right syntax for tr -s right now]

You're not going to be able to do it within procmail, because for scanning the head, procmail's regexp engine treats continuation newlines as spaces. When you extract into $MATCH, there's no way to tell those two spaces from a real pair of adjacent spaces that were there before.


____________________________________________________________
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