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

term_get_userpass_input: support the prompts->utf8 flag.

This continues the programme of UTF-8 support in authentication, begun
in commit f4519b6533 which arranged for console userpass prompts
to function in UTF-8 when the prompts_t asked them to. Since the new
line editing setup works properly when it _is_ in UTF-8 mode, I can
now also arrange that it puts the terminal into UTF-8 mode in the
right circumstances.

I've extended the applicability of the '-legacy-charset-handling' flag
introduced by the commit mentioned above, so that now it's not
specific to the console front end. Now you can give it to GUI PuTTY as
well, which restores the previous (wrong) behaviour of accepting
username and password prompt input in the main session's configured
character set. So if this change breaks someone's workflow, they
should be able to have it back.
This commit is contained in:
Simon Tatham
2023-03-04 13:37:13 +00:00
parent 1a7e4ec8d4
commit f9943e2ffd
7 changed files with 22 additions and 11 deletions

View File

@ -7974,6 +7974,13 @@ static void term_userpass_next_prompt(struct term_userpass_state *s)
}
}
static bool terminal_use_utf8 = true;
bool set_legacy_charset_handling(bool newvalue)
{
terminal_use_utf8 = !newvalue;
return true;
}
/*
* Process some terminal data in the course of username/password
* input.
@ -8000,6 +8007,7 @@ SeatPromptResult term_get_userpass_input(Terminal *term, prompts_t *p)
*/
p->data = s = term_userpass_state_new(term, p);
p->spr = SPR_INCOMPLETE;
term->userpass_utf8_override = p->utf8 && terminal_use_utf8;
/* We only print the `name' caption if we have to... */
if (p->name_reqd && p->name) {
ptrlen plname = ptrlen_from_asciz(p->name);

View File

@ -433,14 +433,18 @@ struct terminal_tag {
/*
* Indicates whether term_get_userpass_input is currently using
* the terminal to present a password prompt or similar.
* the terminal to present a password prompt or similar, and if
* so, whether it's overridden the terminal into UTF-8 mode.
*/
struct term_userpass_state *userpass_state;
bool userpass_utf8_override;
};
static inline bool in_utf(Terminal *term)
{
return term->utf || term->ucsdata->line_codepage == CP_UTF8;
return (term->utf ||
term->ucsdata->line_codepage == CP_UTF8 ||
(term->userpass_state && term->userpass_utf8_override));
}
unsigned long term_translate(