1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Add a Seat vtable method to get a stripctrl.

If centralised code like the SSH implementation wants to sanitise
escape sequences out of a piece of server-provided text, it will need
to do it by making a locale-based StripCtrlChars if it's running in a
console context, or a Terminal-based one if it's in a GUI terminal-
window application.

All the other changes of behaviour needed between those two contexts
are handled by providing reconfigurable methods in the Seat vtable;
this one is no different. So now there's a new method in the Seat
vtable that will construct a StripCtrlChars appropriate to that kind
of seat. Terminal-window seats (gtkwin.c, window.c) implement it by
calling the new stripctrl_new_term(), and console ones use the locale-
based stripctrl_new().
This commit is contained in:
Simon Tatham
2019-03-05 21:13:00 +00:00
parent 36a11ef8d5
commit d60dcc2c82
12 changed files with 51 additions and 0 deletions

View File

@ -388,6 +388,12 @@ static void console_eventlog(LogPolicy *lp, const char *string)
console_logging_error(lp, string);
}
StripCtrlChars *console_stripctrl_new(Seat *seat, BinarySink *bs_out,
bool permit_cr, wchar_t substitution)
{
return stripctrl_new(bs_out, permit_cr, substitution);
}
static void console_data_untrusted(HANDLE hout, const char *data, size_t len)
{
DWORD dummy;

View File

@ -320,6 +320,12 @@ bool win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
return true;
}
StripCtrlChars *win_seat_stripctrl_new(Seat *seat, BinarySink *bs_out,
bool permit_cr, wchar_t substitution)
{
return stripctrl_new_term(bs_out, permit_cr, substitution, term);
}
static size_t win_seat_output(
Seat *seat, bool is_stderr, const void *, size_t);
static bool win_seat_eof(Seat *seat);
@ -347,6 +353,7 @@ static const SeatVtable win_seat_vt = {
nullseat_get_x_display,
nullseat_get_windowid,
win_seat_get_window_pixel_size,
win_seat_stripctrl_new,
};
static Seat win_seat_impl = { &win_seat_vt };
Seat *const win_seat = &win_seat_impl;

View File

@ -105,6 +105,7 @@ static const SeatVtable plink_seat_vt = {
nullseat_get_x_display,
nullseat_get_windowid,
nullseat_get_window_pixel_size,
console_stripctrl_new,
};
static Seat plink_seat[1] = {{ &plink_seat_vt }};