selectel / pyte

Simple VTXXX-compatible linux terminal emulator
http://pyte.readthedocs.org/
GNU Lesser General Public License v3.0
658 stars 102 forks source link

Exit OSC on receipt of C0 string terminator #107

Closed acroz closed 6 years ago

acroz commented 6 years ago

Currently, the pyte stream control sequence parser can enter OSC parsing mode on receipt of either C0 or C1 OSC characters ('\x1b]' and '\x9d' respectively), but would only exit OSC mode on receipt of a BEL ('\x07') or C1 ST character ('\x9c'), but not a C0 ST character ('\x1b\\', i.e. ESC \).

As a result of this, an OSC control character sequence using the C0 string terminator would cause the parser to get 'stuck' in the OSC mode and no further input would be handled correctly.

This PR modifies the parser to collect an additional character after receiving an ESC before applying the 'is this a ST or BEL' logic. We may wish to consider introducing a similar logic for the main loop where C0 OSC and CSI characters are converted to C1 ones (though this would be in a separate PR).

superbobry commented 6 years ago

Good catch! Would you mind adding a changelog entry?

acroz commented 6 years ago

I added a CHANGES entry as requested.

acroz commented 6 years ago

I bound the set of OSC_TERMINATORS to that name, as discussed.

superbobry commented 6 years ago

Merged, thanks!