procmail
[Top] [All Lists]

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

2004-12-14 13:59:23
Hello Udi,

On Mon, 13 Dec 2004, 17:14 GMT+02 Udi Mottelo wrote:

[...]

Subject: hello
<TAB> world

        In this cases if you remove the TAB and SPACE you will
        get:  "helloworld"

yes, the entire situation is much more complicated than I originally
thought. If you have

Subject: Hello =?utf-8?q?wor?=
<TAB><SPC>=?utf-8?q?ld?=

(where <SPC> has to be replaced by a SPACE character and <TAB> by a
TAB), a MUA renders it to display the subject as "Hello world".

If you want procmail to deobfuscate the Subject header (and that's
exactly what I want), you have to remove the entire whitespace at the
beginning of the continuation line. But only in this case, where a
line ends with ENC_SUBJ and is followed by a line where the first
non-whitespace is again ENC_SUBJ. "ENC_SUBJ" stands for a "BQ encoded"
subject construct. So, the necessary steps for the procmail
deobfuscator seem to be:

(1) * $ ^subject:[$WS]+\/.+

($WS is SPACE and TAB)

(2) If MATCH contains ENC_SUBJ, check if it contains a space followed
by a space or TAB:

* $ MATCH ?? "()$SPC[$WS]+"

($SPC is SPACE)

Checking for 2 spaces next to each other would not be sufficient.

(3) save the content of the Subject header in its original state:

my_SUBJECT = `formail -zx subject`

(4) now the nightmare starts... :-)

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