Bug found eating periods from body content

Giganews Newsgroups
Subject: Bug found eating periods from body content
Posted by:  Mr.Ok (mr…@gmx.de)
Date: Mon, 12 Feb 2007

In the unit IdMessageClient, there is a method TIdMessageClient.SendBody(AMsg: TIdMEssage);
To get a RFC conform message body, the following lines duplicates leading periods:

        if (LBodyLine <> '') and (LBodyLine[1] = '.') then begin          {do not localize}
          ATextPart.Body[i] := '.' + LBodyLine;                            {do not localize}

After that, some lines below, the data string is encoded

          LData := Encode(ATextPart.Body[i]) + EOL;

The encode method inserts newlines at column 72 or earlier. If the character next to the linebreak is a period, it is not duplicated anymore.
The result is a missing period in the message body.

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

unit IdCoderQuotedPrintable;
function TIdEncoderQuotedPrintable.Encode(ASrcStream: TIdStream; const ABytes: integer): string;
    Procedure NewLine(const AtPos: integer);
      if AtPos = CurrentPos then begin
        WriteToString('=');  {Do not Localize}
        st.Add(Copy(CurrentLine, 1, CurrentPos-1));
        CurrentPos := 1;
      end else begin
        st.Add(Copy(CurrentLine, 1, AtPos-1)+'='); { Do not Localize }
        // If a line is broken before a period, the data isn't rfc-conform anymore. So duplicate the period.
        // mrOk inserted the next to lines
        if (st[st.count-1] <> '') and (st[st.count-1][1] = '.') then begin          {do not localize}
          st[st.count-1] := '.' + st[st.count-1];                            {do not localize}
        // end of bugfix.
        CurrentPos := CurrentPos-AtPos+1;
        MoveChars(CurrentLine, AtPos, CurrentLine, 1, CurrentPos-1);