Add ANSI processing in ssh client pty code to detect LF to CRLF mode

Whether LF should be changed to CR-LF is determined by what the remote
sshd server wants. Sequences like ESC[20h is sent by sshd servers in pty
ANSI mode. Unix servers usually want LF and Windows servers CR-LF. Added
simple ANSI data check now for pty use in interactive mode. Need to
expand to simple ANSI engine in future for processing other ANSI
terminal attributes.
This commit is contained in:
quamrulmina 2015-10-07 13:54:20 -05:00
parent 522af1564b
commit 545dda2c8b
3 changed files with 23 additions and 3 deletions

View File

@ -2395,8 +2395,9 @@ channel_output_poll(void)
}
}
}
#ifdef WIN32_FIXME
int lftocrlf = 0;
#endif
/* -- protocol input */
/* ARGSUSED */
@ -2452,6 +2453,17 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
}
c->local_window -= win_len;
}
#ifdef WIN32_FIXME
if ( (c->client_tty) && (data_len >= 5) ) {
if ( data[0] == '\033' ) { // escape char octal 33, decimal 27
if ( (data[1] == '[') && (data[2]== '2') && (data[3]== '0') && ( data[4]== 'h' )) {
lftocrlf = 1;
}
}
}
#endif
if (c->datagram)
buffer_put_string(&c->output, data, data_len);
else

View File

@ -1320,6 +1320,14 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr,
* and append it to the buffer.
*/
last_was_cr = (ch == '\r' || ch == '\n');
#ifdef WIN32_FIXME
extern int lftocrlf ; // defined in channels.c file's channel_input_data() function for now
if ( (lftocrlf == 1) && ( ch == '\n') ) {
// add a \r before \n if sshd server sent us ESC[20h during initial tty mode setting
buffer_put_char(bin, '\r');
bytes++;
}
#endif
buffer_put_char(bin, ch);
bytes++;
}

View File

@ -2,5 +2,5 @@
#define SSH_VERSION "OpenSSH_7.1"
#define SSH_PORTABLE "p1 Microsoft Pragma Win32 port Sep 30 2015"
#define SSH_PORTABLE "p1 Microsoft Pragma Win32 port Oct 7 2015"
#define SSH_RELEASE SSH_VERSION SSH_PORTABLE