Re: TIdDecoderMIME (Uneven size in DecodeToStream)

Giganews Newsgroups
Subject: Re: TIdDecoderMIME (Uneven size in DecodeToStream)
Posted by:  Paul Kuczora (ne…@browserlock.com)
Date: Tue, 2 Sep 2003

This workround was posted on this group by "news.nerim.net" back in July.

That problem had been bugging me for months!

Previous posting follows............

    This beahvior occur when an attachment line have an odd number of byte.
(Don't know if it's legal, but it is easy enough to decode correctly with a
slight modification in IdMessageCoderMIME.pas).

          if LDecoder is TIdDecoderQuotedPrintable then begin
            LDecoder.DecodeToStream(LLine+EOL,ADestStream);
// Add this
          end else if LDecoder is TIdDecoder4to3 then begin
            LLine:=LBackLog+LLine;
            lBackLog:='';
        if (Length(LLine) mod 4) > 0 then begin
            LBackLog:=Copy(LLine,4*(Length(LLine) div
4)+1,Length(LLine)-(Length(LLine) div 4)*4);
              LLine:=Copy(LLine,1,4*(Length(LLine) div 4));
            end;
            LDecoder.DecodeToStream(LLine, ADestStream);
//
          end else if LLine <> '' then begin
            LDecoder.DecodeToStream(LLine, ADestStream);
          end;

Paul Kuczora.

"David S." <no@spam.please> wrote in message
news:69BE5D212C7DE240no@spam.please...
>
>  I'm using TIdDecoderMIME from C++ Builder 6 UP 4, Indy 9.0.14. It
reports
> an error: "Uneven size in DecodeToStream.". This is a peace of C++ code:
>
> String __fastcall Decode(String cInput)
> {
>  TIdDecoderMIME *pDecoder = new TIdDecoderMIME(NULL);
>  String cResult;
>  try {
>    try {
>      cResult = pDecoder->DecodeToString(cInput);
>    } __finally {
>      delete pDecoder;
>    }
>  } catch (Exception &e) {
>    Error(e.Message);
>    return "";
>  }
>  return cResult;
> }
>
>    Well, it works fine except decoding this:
>
MIIDCzCCAfOgAwIBAgICAKkwDQYJKoZIhvcNAQEFBQAwQDEQMA4GA1UECxMHRGVtbyBDQTEOMAwG
>
A1UECxMFU0ktQ0ExDzANBgNVBAoTBlNFVENDRTELMAkGA1UEBhMCU0kwHhcNMDIxMDMwMTIzMDM0
>
WhcNMDMxMDMwMTIzMDM0WjA8MQswCQYDVQQGEwJTSTEPMA0GA1UEChMGU0VUQ0NFMRwwGgYDVQQD
>
ExNhbnNwaXJpeC5zZXRjY2Uub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCti+gwRgQM
>
fwbt644cyA/pNXszGh+KAKEetK39TotpSTPBudb4z6ughg8N7VDPbAhjI+YEBo/6SMIfGhrmgmDi
>
4Sq4d4W6zpWRlc4dhZ1NNVtxrv+EXnjUndiTl+5taXMblTV+NR+ylJIBlRiZoZSoawlbBEMOPya0
>
kx5rhTQ+gwIDAQABo4GWMIGTMCAGCWCGSAGG+EIBDQQTFhFOT1QgQVVUSEVOVElDQVRFRDARBglg
>
hkgBhvhCAQEEBAMCAEAwDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCBLAwHQYDVR0OBBYEFDwJ
>
SIFzQrY8nLARBVFL/krEQ59NMB8GA1UdIwQYMBaAFAxudGd8OZKPkwBuoby5yiSTLkS2MA0GCSqG
>
SIb3DQEBBQUAA4IBAQBMxq2vEA0/8f0szAbCzkQpxo4NjkPRhQuiUvGN7N+ATYzYT4Qx1m6fCdpG
>
0Ei81pOvr0VfP9KzE8zMPyyj5tQsJ6n+aLpmiRjCDtZcDQ4E7rTTCCXL4JlQHX9ZmLeKxwWJTQbS
>
V3TSzHewi18cbxzH/8aQV6wbKOHkg6X9ceL/Qo/gUoc2ujTAnD8M602cNi2AfgVTx2zO0TX18dpp
>
SpmtwvbplX94S4wKYBbxzqqWhqwBUOaH1VW4empkQcyy8F8+iQtyWpMQKwJnhHjNnI+vm7fnvIXy
> 05YeFPn+zrGp9yhdIYtc7b+WUlJexXAEliGpogW71mqjH/6q9s+jUDYE
>
>    This was working fine, before upgrading from standard Indy components
> that ships with BCB6 to the new Indy 9.0.14.

Replies

In response to

TIdDecoderMIME (Uneven size in DecodeToStream) posted by David S. on Mon, 1 Sep 2003