mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-20 20:44:50 +02:00
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:
parent
522af1564b
commit
545dda2c8b
16
channels.c
16
channels.c
@ -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
|
||||
|
@ -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++;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user