procmail
[Top] [All Lists]

Re: unfold Subject line that is wrapped

2000-06-23 09:00:40
mark david mcCreary <mdm(_at_)internet-tools(_dot_)com> writes:
I have an email message that wraps the Subject line, and I want to put it
back together again.
...
Subject: Re: X-Command maintaner password subscribe 
elxtina(_at_)xxitqfrazatronixx(_dot_)co
      m
...
The Subject line has a newline, tab, letter "m", newline at the end.

I want to squeeze that all back together, with no spaces so it becomes a
valid email address.

Whatever program that did the folding to begin with is *broken*, as it
has _changed_ the semantics!  The semantics of line wrapping are that
the newline is to be ignored, but the whitespace after it _is_ part of
the content of the header.  Therefore, the Subject: header field above
contains seven 'words', not six.  The program that wrapped the header
inserted a tab into the last word.

So, how can you tell when it is 'safe' to glue together two words?


If you can figure that one out, you'll have to teach it to an external
program like sed or perl: there is no (reliable) way to detect whether
or where a header field is folded using a procmail regexp, as procmail
converts the folding newlines to spaces during regexp processing.  Only
an external program will be able to tell.


(This behavior in procmail actually contains a bug: the newlines should
not be replaced by spaces but rather completely removed as far as the
regexp engine is concerned.  For example, the header field:

Subject: foo
 bar

currently appears to have two spaces between the "foo" and "bar", when
it should really appear to have one space between them.  This is
generally harmless (there's already one whitespace character there,
after all) but it does mean that even when you are confidently expecting
a single whitespace character, you should probably use "[       ]+"
instead of just "[      ]", as an unlucky wrap may cause a spurious
space to appear in procmail's view.)


Philip Guenther

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