mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-04 04:52:47 -05:00
Add a per-line 'trusted' status in Terminal.
This indicates that a line contains trusted information (originated by PuTTY) or untrusted (from the server). Trusted lines are prefixed by a three-column signature consisting of the trust sigil (i.e. PuTTY icon) and a separating space. To protect against a server using escape sequences to move the cursor back up to a trusted line and overwrite its contents, any attempt to write to a termline is preceded by a call to check_trust_status(), which clears the line completely if the terminal's current trust status is different from the previous state of that line. In the terminal data structures, the trust sigil is represented by 0xDFFE (an otherwise unused value, because it's in the surrogate space). For bidi purposes I've arranged to treat that value as direction-neutral, so that it will appear on the right if a terminal line needs it to. (Not that that's currently likely to happen, with PuTTY not being properly localised, but it's a bit of futureproofing.) The bidi system is also where I actually insert the trust sigil: the _logical_ terminal data structures don't include it. term_bidi_line was a convenient place to add it, because that function was already transforming a logical terminal line into a physical one in a way that also generates a logical<->physical mapping table for handling mouse clicks and cursor positioning; so that function now adds the trust sigil as well as running the bidi algorithm. (A knock-on effect of _that_ is that the log<->phys position map now has to have a value for 'no correspondence', because if the user does click on the trust sigil, there's no logical terminal position corresponding to that. So the map can now contain the special value BIDI_CHAR_INDEX_NONE, and anyone looking things up in it has to be prepared to receive that as an answer.) Of course, this terminal-data transformation can't be kept _wholly_ within term_bidi_line, because unlike proper bidi, it actually reduces the number of visible columns on the line. So the wrapping code (during glyph display and also copy and paste) has to take account of the trusted status and use it to ignore the last 3 columns of the line. This is probably not done absolutely perfectly, but then, it doesn't need to be - trusted lines will be filled with well-controlled data generated from the SSH code, which won't be doing every trick in the book with escape sequences. Only untrusted terminal lines will be using all the terminal's capabilities, and they don't have this sigil getting in the way.
This commit is contained in:
2
putty.h
2
putty.h
@ -1627,6 +1627,7 @@ void term_provide_logctx(Terminal *term, LogContext *logctx);
|
||||
void term_set_focus(Terminal *term, bool has_focus);
|
||||
char *term_get_ttymode(Terminal *term, const char *mode);
|
||||
int term_get_userpass_input(Terminal *term, prompts_t *p, bufchain *input);
|
||||
void term_set_trust_status(Terminal *term, SeatTrustStatus status);
|
||||
|
||||
typedef enum SmallKeypadKey {
|
||||
SKK_HOME, SKK_END, SKK_INSERT, SKK_DELETE, SKK_PGUP, SKK_PGDN,
|
||||
@ -1977,6 +1978,7 @@ void setup_config_box(struct controlbox *b, bool midsession,
|
||||
/*
|
||||
* Exports from minibidi.c.
|
||||
*/
|
||||
#define BIDI_CHAR_INDEX_NONE ((unsigned short)-1)
|
||||
typedef struct bidi_char {
|
||||
unsigned int origwc, wc;
|
||||
unsigned short index, nchars;
|
||||
|
Reference in New Issue
Block a user