Bug decoding long subject

Giganews Newsgroups
Subject: Bug decoding long subject
Posted by:  Ivan Cruz (iv…@artha.com.br)
Date: Tue, 05 Apr 2005

It's an old Indy 9 bug that (I believe) is still present
in Indy 10. Please consider the following smtp header

Subject: =?iso-8859-1?Q?teste_1.12.b-_fax_sem_anexo_c?=

It's a long subject with accented characters. The line is
folded and in the process, every part gets it's own encoding

TIdHeaderList.GetValueFromLine will return the subject with
two extra spaces: between the first and second and the second
and third lines.

DecodeHeader, by it's way, will keep the extra spaces in the
subject and, in the and of day, I have:

teste_1.12.b- fax sem anexo c<extraSpace>om texto no corpo do email,
pedindo <extraSpace>notificação

When the extra space brokes a word, like the example, the
customer gets mad.

I wrote a temporary circunvent till a more clean and oficial
solution can be found. In TIdMessage.ProcessHeaders:

  function stripExtraSpace ( header: String ): String;
      Result := StringReplace ( header, '?= =?', '?==?', [ rfReplaceAll
] );


  Subject := DecodeHeader ( stripExtraSpace ( Headers.Values['Subject']
) ); {do not localize}

Thanks for your atention.

Ivan Cruz.