1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-30 20:35:38 +02:00

Bug 477702 - Telnet line ending needs to be CRLF

This commit is contained in:
Anton Leherbauer 2015-10-01 12:35:46 +02:00
parent 02cf48046f
commit 194f4e2611
2 changed files with 25 additions and 11 deletions

View file

@ -20,6 +20,7 @@
*******************************************************************************/
package org.eclipse.tm.terminal.connector.telnet.connector;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -110,7 +111,29 @@ public class TelnetConnector extends TerminalConnectorImpl {
fInputStream = inputStream;
}
private void setOutputStream(OutputStream outputStream) {
fOutputStream = outputStream;
if (outputStream == null) {
fOutputStream = null;
return;
}
// send LF after CR (telnet end-of-line sequence - RFC 854)
fOutputStream = new FilterOutputStream(outputStream) {
final byte CR = 13;
final byte LF = 10;
final byte[] CRLF = { CR, LF };
int last = -1;
@Override
public void write(int b) throws IOException {
if (b == LF && last == CR) {
last = b;
return;
}
last = b;
if (b == CR)
out.write(CRLF);
else
out.write(b);
}
};
}
Socket getSocket() {
return fSocket;

View file

@ -562,6 +562,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
}
protected void sendString(String string) {
Logger.log(string);
try {
// Send the string after converting it to an array of bytes using the
// platform's default character encoding.
@ -1182,16 +1183,6 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC
//handling unnecessary further up.
sendChar(character, altKeyPressed);
// Special case: When we are in a TCP connection and echoing characters
// locally, send a LF after sending a CR.
// ISSUE: Is this absolutely required?
if (character == '\r' && getTerminalConnector() != null
&& isConnected()
&& getTerminalConnector().isLocalEcho()) {
sendChar('\n', false);
}
// Now decide if we should locally echo the character we just sent. We do
// _not_ locally echo the character if any of these conditions are true:
//