~vcs-imports/putty/master

« back to all changes in this revision

Viewing changes to terminal/terminal.c

  • Committer: Simon Tatham
  • Date: 2023-10-19 17:55:04 UTC
  • Revision ID: git-v1:7b10e34b8f636008243df1a1add61c0763befb38
Recognise and discard the APC terminal escape sequence.

I encountered an instance of this sequence in the log files from a
clang CI build. The payload text inside the wrapper was
"bk;t=1697630539879"; I don't know what the "bk" stood for, but the
second half appears to be a timestamp in milliseconds since the Unix
epoch.

I don't think there's anything we can (or should) actually _do_ with
this sequence, but I think it's useful to at least recognise it, so
that it can be conveniently discarded.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3179
3179
 */
3180
3180
static void do_osc(Terminal *term)
3181
3181
{
 
3182
    if (term->osc_is_apc) {
 
3183
        /* This OSC was really an APC, and we don't support that
 
3184
         * sequence at all. We only recognise it in order to ignore it
 
3185
         * and filter it out of input. */
 
3186
        return;
 
3187
    }
 
3188
 
3182
3189
    if (term->osc_w) {
3183
3190
        while (term->osc_strlen--)
3184
3191
            term->wordness[(unsigned char)term->osc_string[term->osc_strlen]] =
4106
4113
                    /* Compatibility is nasty here, xterm, linux, decterm yuk! */
4107
4114
                    compatibility(OTHER);
4108
4115
                    term->termstate = SEEN_OSC;
 
4116
                    term->osc_is_apc = false;
 
4117
                    term->osc_strlen = 0;
 
4118
                    term->esc_args[0] = 0;
 
4119
                    term->esc_nargs = 1;
 
4120
                    break;
 
4121
                  case '_':             /* APC: application program command */
 
4122
                    /* APC sequences are just a string, terminated by
 
4123
                     * ST or (I've observed in practice) ^G. That is,
 
4124
                     * they have the same termination convention as
 
4125
                     * OSC. So we handle them by going straight into
 
4126
                     * OSC_STRING state and setting a flag indicating
 
4127
                     * that it's not really an OSC. */
 
4128
                    compatibility(OTHER);
 
4129
                    term->termstate = SEEN_OSC;
 
4130
                    term->osc_is_apc = true;
4109
4131
                    term->osc_strlen = 0;
4110
4132
                    term->esc_args[0] = 0;
4111
4133
                    term->esc_nargs = 1;