@Remy Lebeau: As I understand it, you say: If the server sends you IAC DO ECHO, TIdTelnet is hard-coded to send an IAC WILL ECHO response, and then fires the OnTelnetCommand ( tncEcho ) event so that you can respond to everything you get.
This makes sense and is consistent with what RFC857 offers ...
However, the code has:
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;
Is this code wrong? (in version 10.6.0.497 from Indy)
I believe this makes 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 // (ie local echo is usually still implicit in this) end;
In other words, I believe that the code is currently replaced with what it should be - that the server sending DO ECHO should create the tncEcho token - this is what you said in the above quote!
How did this mistake survive for so long? (probably because most Telnet servers no longer bother with RFC857 echo matching)
Unfortunately, the only way I can βcompensateβ for this error at the moment is to create a copy of the IDTelnet.pas file; associate this with your project in the Project Manager; and then make corrections to this copy as described above.
source share