1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-04-11 08:08:06 -05:00

Switch console prompt sanitisation to use StripCtrlChars.

Local functions in uxcons.c and wincons.c were calling the old
simplistic sanitise_term_data to print console-based prompts. Now they
use the same new system as everything else.

This removes the last use of the ASCII-centric sanitise_term_data.
This commit is contained in:
Simon Tatham 2019-03-05 21:04:08 +00:00
parent b9c74e84dc
commit 7b48922761
2 changed files with 12 additions and 2 deletions

View File

@ -499,9 +499,14 @@ static void console_close(FILE *outfp, int infd)
static void console_prompt_text(FILE *outfp, const char *data, size_t len)
{
bufchain sanitised;
bufchain_sink bs;
bufchain_init(&sanitised);
sanitise_term_data(&sanitised, data, len);
bufchain_sink_init(&bs, &sanitised);
StripCtrlChars *scc = stripctrl_new(BinarySink_UPCAST(&bs), false, 0);
put_data(scc, data, len);
stripctrl_free(scc);
while (bufchain_size(&sanitised) > 0) {
ptrlen sdata = bufchain_prefix(&sanitised);
fwrite(sdata.ptr, 1, sdata.len, outfp);

View File

@ -398,9 +398,14 @@ static void console_data_untrusted(HANDLE hout, const char *data, size_t len)
{
DWORD dummy;
bufchain sanitised;
bufchain_sink bs;
bufchain_init(&sanitised);
sanitise_term_data(&sanitised, data, len);
bufchain_sink_init(&bs, &sanitised);
StripCtrlChars *scc = stripctrl_new(BinarySink_UPCAST(&bs), false, 0);
put_data(scc, data, len);
stripctrl_free(scc);
while (bufchain_size(&sanitised) > 0) {
ptrlen sdata = bufchain_prefix(&sanitised);
WriteFile(hout, sdata.ptr, sdata.len, &dummy, NULL);