mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 01:18:00 +00: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:
parent
1a7e4ec8d4
commit
f9943e2ffd
@ -934,7 +934,7 @@ int cmdline_process_param(const char *p, char *value,
|
||||
!strcmp(p, "-legacy_charset_handling")) {
|
||||
RETURN(1);
|
||||
SAVEABLE(0);
|
||||
if (!console_set_legacy_charset_handling(true)) {
|
||||
if (!set_legacy_charset_handling(true)) {
|
||||
cmdline_report_unavailable(p);
|
||||
return ret;
|
||||
}
|
||||
|
6
putty.h
6
putty.h
@ -2516,7 +2516,6 @@ bool have_ssh_host_key(const char *host, int port, const char *keytype);
|
||||
extern bool console_batch_mode, console_antispoof_prompt;
|
||||
extern bool console_set_batch_mode(bool);
|
||||
extern bool console_set_stdio_prompts(bool);
|
||||
extern bool console_set_legacy_charset_handling(bool);
|
||||
SeatPromptResult console_get_userpass_input(prompts_t *p);
|
||||
bool is_interactive(void);
|
||||
void console_print_error_msg(const char *prefix, const char *msg);
|
||||
@ -2525,6 +2524,11 @@ void console_print_error_msg_fmt_v(
|
||||
void console_print_error_msg_fmt(const char *prefix, const char *fmt, ...)
|
||||
PRINTF_LIKE(2, 3);
|
||||
|
||||
/*
|
||||
* Exports from either console frontends or terminal.c.
|
||||
*/
|
||||
extern bool set_legacy_charset_handling(bool);
|
||||
|
||||
/*
|
||||
* Exports from printing.c in platform subdirs.
|
||||
*/
|
||||
|
@ -13,8 +13,3 @@ bool console_set_stdio_prompts(bool newvalue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool console_set_legacy_charset_handling(bool newvalue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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(
|
||||
|
@ -578,7 +578,7 @@ bool console_set_stdio_prompts(bool newvalue)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool console_set_legacy_charset_handling(bool newvalue)
|
||||
bool set_legacy_charset_handling(bool newvalue)
|
||||
{
|
||||
/* This probably _will_ need to be supported, but isn't yet. */
|
||||
return false;
|
||||
|
@ -56,7 +56,7 @@ bool console_set_stdio_prompts(bool newvalue)
|
||||
}
|
||||
|
||||
static bool conio_use_utf8 = true;
|
||||
bool console_set_legacy_charset_handling(bool newvalue)
|
||||
bool set_legacy_charset_handling(bool newvalue)
|
||||
{
|
||||
conio_use_utf8 = !newvalue;
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user