From bce02aaabbebdb3e66e1f0d98b1060dcefe55855 Mon Sep 17 00:00:00 2001 From: James Holderness Date: Sun, 11 Sep 2022 20:28:02 +0100 Subject: [PATCH] Make sure Terminal state machine always accepts C1 controls. --- src/cascadia/TerminalCore/Terminal.cpp | 2 +- src/terminal/parser/stateMachine.cpp | 2 +- src/terminal/parser/stateMachine.hpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 1cf4528a569..6e9a3be7b19 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -91,7 +91,7 @@ void Terminal::Create(til::size viewportSize, til::CoordType scrollbackLines, Re // But if they are being accepted by conhost, there's a chance they may get // passed through in some situations, so it's important that our state // machine is always prepared to accept them. - _stateMachine->SetParserMode(StateMachine::Mode::AcceptC1, true); + _stateMachine->SetParserMode(StateMachine::Mode::AlwaysAcceptC1, true); } // Method Description: diff --git a/src/terminal/parser/stateMachine.cpp b/src/terminal/parser/stateMachine.cpp index 21ee4a88efb..36848694f32 100644 --- a/src/terminal/parser/stateMachine.cpp +++ b/src/terminal/parser/stateMachine.cpp @@ -1716,7 +1716,7 @@ void StateMachine::ProcessCharacter(const wchar_t wch) // code points that get translated as C1 controls when that is not their // intended use. In order to avoid them triggering unintentional escape // sequences, we ignore these characters by default. - if (_parserMode.test(Mode::AcceptC1)) + if (_parserMode.any(Mode::AcceptC1, Mode::AlwaysAcceptC1)) { ProcessCharacter(AsciiChars::ESC); ProcessCharacter(_c1To7Bit(wch)); diff --git a/src/terminal/parser/stateMachine.hpp b/src/terminal/parser/stateMachine.hpp index c3c3936693b..41bce50f97e 100644 --- a/src/terminal/parser/stateMachine.hpp +++ b/src/terminal/parser/stateMachine.hpp @@ -50,6 +50,7 @@ namespace Microsoft::Console::VirtualTerminal enum class Mode : size_t { AcceptC1, + AlwaysAcceptC1, Ansi, };