[exim] Unfold and rewrite multi-line headers

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Dmitriy Matrosov
Dátum:  
Címzett: exim-users
Tárgy: [exim] Unfold and rewrite multi-line headers
Hi.

Can exim unfold and decode entire multiline header (`Subject` particularly)?

Here is the first part of multiline header:

     Subject: 
=?UTF-8?B?RndkOiBVUkdFTlQ6IFtOb3RpY2UgSUQgKndtVVJwRCpdINCY0YHQv9C+?=\n


=?UTF-8?B?0LvRjNC30L7QstCw0L3QuNC1INC40L3RgtC10LvQu9C10LrRgtGD0LDQu9GM0L0=?=


I've tried several variants.

`$h_Subject:` decodes only until first newline:

     Subj_h: Fwd: URGENT: [Notice ID *wmURpD*] 
\320\230\321\201\320\277\320\276\n 
=?UTF-8?B?0LvRjNC30L7QstCw0L3QuNC1INC40L3RgtC10LvQu9C10LrRgtGD0LDQu9GM0L0=?=\n


Then i've tried to use `sg` to replace newlines in raw header with comma and
use `reduce` to decode each part using `rfc2047d`, but that didn't work,
because it turns out exim is only able to decode the first chunk:

     # exim -be 
'${rfc2047d:=?UTF-8?B?RndkOiBVUkdFTlQ6IFtOb3RpY2UgSUQgKndtVVJwRCpdINCY0YHQv9C+?=}'
     Fwd: URGENT: [Notice ID *wmURpD*] Испо


     # exim -be 
'${rfc2047d:=?UTF-8?B?0LvRjNC30L7QstCw0L3QuNC1INC40L3RgtC10LvQu9C10LrRgtGD0LDQu9GM0L0=?=}'


=?UTF-8?B?0LvRjNC30L7QstCw0L3QuNC1INC40L3RgtC10LvQu9C10LrRgtGD0LDQu9GM0L0=?=

But the second chunk is also valid base64:

     # echo 
'0LvRjNC30L7QstCw0L3QuNC1INC40L3RgtC10LvQu9C10LrRgtGD0LDQu9GM0L0=' | 
base64 -d
     льзование интеллектуальн


So, may be it's not valid per rfc2047, i don't know, but Thunderbird still
decodes the entire header successfully.. But that was only the decoding
part.

The other part was to add something to this header (and break DKIM, yes, i
remember, thanks Mike Brudenell for reminding me about this, when i
wanted to
modify attached file extension).

Here first i've tried to modify decoded header and then encode it with
`rfc2047`:

     Subj_h2: ${rfc2047:***** VIRUS ***** $h_Subject:}


but that results in double-encoding:

     Subj_h2: 
=?UTF-8?Q?*****_VIRUS_*****_Fwd=3A_URGENT=3A_=5BNotice_ID_*wmURpD*=5D_?= 
=?UTF-8?Q?=D0=98=D1=81=D0=BF=D0=BE=0A_=3D=3FUTF-8=3FB=3F0LvRjNC30L7Q?=


And the only method, that seems to output somethiing similar to correct,
is to
encode just the text i want to add and prepend it to raw header, like:

     ${rfc2047:***** VIRUS *****}\n $rh_Subject:


Subject: ***** VIRUS *****
=?UTF-8?B?RndkOiBVUkdFTlQ6IFtOb3RpY2UgSUQgKndtVVJwRCpdINCY0YHQv9C+?=

=?UTF-8?B?0LvRjNC30L7QstCw0L3QuNC1INC40L3RgtC10LvQu9C10LrRgtGD0LDQu9GM0L0=?=


So, is there something wrong with this particular `Subject` header or
exim always
decodes only first line of multiline header? And are there some
pitfalls, that
i didn't notice, when modifying header? Or may there is a better way to
do it?

--
     Dmitriy