Indy 9 QuotedPrintable changes ...

Giganews Newsgroups
Subject: Indy 9 QuotedPrintable changes ...
Posted by:  Vincent Lemieux (vincentlemie…@yahoo.com)
Date: Tue, 9 Mar 2004

Hi!

I use Indy 9 and I made some modifications to the IdMessageClient.pas and
IdCoderQuotedPrintable.pas files.

Here is what I made and why I made it.
I'm sorry if I'm not posting in the good group.
I wanted to share what I did and I would also like to have a feedback from
the Indy guys to know if I'm missing something or if I'm doing it right.

My problem was that I had a line in a message that had 70 characters.
When calling TIdEncoderQuotedPrintable.EncodeString, from
IdMessageClient.pas, Indy was adding 2 characters (#13 and #10).
So the string to encode was of 72 characters.

I changed the EncodeString function in IdCoderQuotedPrintable.pas ...
First of all I replaced this part ...
if Length(Line) > 71 then
  begin
  NewLine;
  end;  //if Length(Line > 71 then

by this one ...
if (Length(Line) > 71) AND (Not (i = LBufSize)) then { !"/ VINCENT 2 MARS
2004 }
  begin
  NewLine;
  end;  //if Length(Line > 71 then

This has the effect to not create a new line at 72 characters if there is no
more characters to add.
With the old code, it created a new line beginning with a = character
because the 72nd character was between the #13 and #10.
This was creating some strange behavior when displaying a message.

This solved my problem.

Then to be sure to not have this problem again, I made a change to the
idMessageClient.pas file ...
I change this line in IdMessageClient.pas ...
Data := TIdEncoderQuotedPrintable.EncodeString(ATextPart.Body[i] + EOL);
for the following line ...
Data := TIdEncoderQuotedPrintable.EncodeString(ATextPart.Body[i]); { !"/
VINCENT 2 MARS 2004 }
I removed the EOL characters from the string. This way, I am sure that I
will not add #13 or #10 characters at the end of a line.

Because I removed the EOL characters when calling EncodeString, I had no
extra system EOL so I commented the following part of code...
    //Delete an extra system EOL that was added by the TStrings itself
    //The EOL varies from system to system { MIS EN COMMENTAIRE PAR VINCENT
2 MARS 2004 }
//*    i := Length(sLineBreak); { !"/ VINCENT 2 MARS 2004}
//*    if (Length(Result)>i) then
//*    begin
//*      Delete(Result,Length(Result) - i+1,i);
//*    end;

Since I made theses changes I had no other problems.
So, for now, I think my changes are OK but I would really like someone from
the Indy Team to give me a feedback about these changes.

Thanks a lot!

--
Vincent Lemieux
vincentlemie…@yahoo.com

Replies