Re: Bug found eating periods from body content

Giganews Newsgroups
Subject: Re: Bug found eating periods from body content
Posted by:  Remy Lebeau (Indy Team) (no.spam@no.spam.com)
Date: Mon, 12 Feb 2007

"Mr.Ok" <mr…@gmx.de> wrote in message
news:C4B48369B71AE340mr…@gmx.de...

> I fixed that by adding the three lines from the SendBody method:

That is not the correct way to go.  The encoders have no business
knowing anything about the period handling at all.  That is not their
responsiblity.  The proper thing to do is to not duplicate the period
at all while encoding.  The duplicating need to occur only when
actually sending the data.  In other words, change this code:

    LData := '';
    for i := 0 to ATextPart.Body.Count - 1 do begin
        LBodyLine := ATextPart.Body[i];
        if (LBodyLine <> '') and (LBodyLine[1] = '.') then begin
            ATextPart.Body[i] := '.' + LBodyLine;
        end;
        with TIdEncoderQuotedPrintable.Create do try
            LData := Encode(ATextPart.Body[i] + EOL);
        finally Free; end;
        if TransferEncoding = iso2022jp then begin
            IOHandler.Write(Encode2022JP(LData))
        end else begin
            IOHandler.Write(LData);
        end;
    end;

To this code instead:

    for i := 0 to ATextPart.Body.Count - 1 do begin
        with TIdEncoderQuotedPrintable.Create do try
            LData := Encode(ATextPart.Body[i] + EOL);
        finally Free; end;
        if TransferEncoding = iso2022jp then begin
            LData := Encode2022JP(LData);
        end;
        if (LData <> '') and (LData[1] = '.') then begin
            LData := '.' + LData;
        end;
        IOHandler.Write(LData);
    end;

Gambit

Replies

In response to

Bug found eating periods from body content posted by Mr.Ok on Mon, 12 Feb 2007