Bug: BCC is send with the headers after LoadFromFile

Giganews Newsgroups
Subject: Bug: BCC is send with the headers after LoadFromFile
Posted by:  Alex Ivlev (nospam@nospam.net)
Date: Fri, 8 Sep 2006

BCC is the one header that's not supposed to be sent out with the message.
And normally that works fine: procedure TIdMessage.GenerateHeader does not
generate a header line for BCC. Except one case - when the message is saved
to file then BCC is saved with it. But when it's loaded back, procedure
TIdMessage.LoadFromStream forgets to remove that line. So when the message
is sent after that - it's sent by procedure TIdMessageClient.SendMsg with
the BCC header intact, if the NoEncode property is True (if NoEncode = False
then the headers are re-generated without BCC).

Here is a fix for this situation (the 1 added line is marked):

procedure TIdMessage.LoadFromStream(AStream: TIdStream; const AHeadersOnly:
Boolean = False);
begin
  // clear message properties, headers before loading
  Clear;
  with TIdMessageClient.Create do try
    ProcessMessage(Self, AStream, AHeadersOnly);
  finally Free; end;
  Headers.Values['Bcc'] := '';  // clear saved Bcc!!
end;

Can this be added to the code?

Replies