@Remy Lebeau: As I understand it, you're saying:
If the server sends an IAC DO ECHO to you, TIdTelnet is hard-coded to send an IAC WILL ECHO response, and then triggers an OnTelnetCommand( tncEcho ) event to tell you to echo back whatever you receive.
That makes sense and agrees with what the RFC857 sets out to achieve...
However, in the code we have:
procedure TIdTelnet.Negotiate;
...
TNC_DONT:
begin
b := IOHandler.ReadByte;
case b of
TNO_ECHO:
begin
DoTelnetCommand(tncEcho);
//DoStatus('ECHO'); {Do not Localize}
Reply := TNC_WONT;
end;
else
Reply := TNC_WONT;
end;
and
TNC_DO:
begin
b := IOHandler.ReadByte;
case b of
TNO_ECHO:
begin
Reply := TNC_WILL;
DoTelnetCommand(tncLocalEcho);
end;
Surely this code is not correct? (in version 10.6.0.497 of Indy)
I believe this would make more sense:
procedure TIdTelnet.Negotiate;
...
TNC_DONT:
begin
b := IOHandler.ReadByte;
case b of
TNO_ECHO:
begin
// Agree not to echo back everything received from server
// (This being the default - you shouldn't echo unless asked to)
Reply := TNC_WONT;
// Therefore only print locally what is sent to server
// (Again: this is the default behavior without negotiation)
DoTelnetCommand(tncLocalEcho);
end;
else
Reply := TNC_WONT;
end;
and
TNC_DO:
begin
b := IOHandler.ReadByte;
case b of
TNO_ECHO:
begin
// Agree to echo back everything received from server
Reply := TNC_WILL;
DoTelnetCommand(tncEcho);
// Therefore you may still have to locally print what you send
// (i.e. local echo is usually still implicit in this)
end;
In other words, I believe the code is presently swapped from what it should be - which is that the server sending DO ECHO should beget the tncEcho token - which is what you said in the above quote!
How has this bug survived this long? (probably because most Telnet servers don't bother with RFC857 echo negotiation any more)
Unfortunately the only way I see to "compensate" for this bug at the moment is to create a copy of the IDTelnet.pas file; link that to your project in the Project Manager; and then make the corrections to that copy as outlined above.