From 03c48ab024362163da3b1a1b07cc245dc0ea4925 Mon Sep 17 00:00:00 2001 From: "System user; root" Date: Thu, 20 Jul 2023 20:33:54 +0100 Subject: [PATCH] Do not emit control characters in title reports Signed-off-by: Martin Kemp Co-authored-by: David Leadbeater --- src/ConEmuCD/ConAnsiImpl.cpp | 2 +- src/ConEmuHk/Ansi.cpp | 2 +- src/common/WConsole.h | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ConEmuCD/ConAnsiImpl.cpp b/src/ConEmuCD/ConAnsiImpl.cpp index 9ae09d2633..18b6d156a0 100644 --- a/src/ConEmuCD/ConAnsiImpl.cpp +++ b/src/ConEmuCD/ConAnsiImpl.cpp @@ -985,7 +985,7 @@ bool SrvAnsiImpl::ReportString(LPCWSTR asRet) LPCWSTR pc = asRet; for (int i = 0; i < nLen; i++, p++, pc++) { - const char ch = (wcschr(UNSAFE_CONSOLE_REPORT_CHARS, *pc) == nullptr) ? *pc : L' '; + const char ch = *pc >= 0x20 ? *pc : L' '; p->EventType = KEY_EVENT; p->Event.KeyEvent.bKeyDown = TRUE; p->Event.KeyEvent.wRepeatCount = 1; diff --git a/src/ConEmuHk/Ansi.cpp b/src/ConEmuHk/Ansi.cpp index ad09771460..56fda7331a 100644 --- a/src/ConEmuHk/Ansi.cpp +++ b/src/ConEmuHk/Ansi.cpp @@ -2505,7 +2505,7 @@ BOOL CEAnsi::ReportString(LPCWSTR asRet) LPCWSTR pc = asRet; for (size_t i = 0; i < nLen; i++, p++, pc++) { - const char ch = (wcschr(UNSAFE_CONSOLE_REPORT_CHARS, *pc) == nullptr) ? *pc : L' '; + const char ch = *pc >= 0x20 ? *pc : L' '; p->EventType = KEY_EVENT; p->Event.KeyEvent.bKeyDown = TRUE; p->Event.KeyEvent.wRepeatCount = 1; diff --git a/src/common/WConsole.h b/src/common/WConsole.h index 240605eec4..b855a690ab 100644 --- a/src/common/WConsole.h +++ b/src/common/WConsole.h @@ -52,9 +52,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define DISABLE_NEWLINE_AUTO_RETURN 0x0008 #endif -// These keys should not be reported back to console input -#define UNSAFE_CONSOLE_REPORT_CHARS L"\r\n\t" - struct MY_CONSOLE_SCREEN_BUFFER_INFOEX { ULONG cbSize;