Harden Windows terminal raw input mode
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
ci / test (push) Canceled after 0s
ci / fuzz-smoke (push) Canceled after 0s
ci / macos-client (macos-aarch64, macos-14) (push) Canceled after 0s
ci / macos-client (macos-x86_64, macos-13) (push) Canceled after 0s
ci / windows-client (push) Canceled after 0s
ci / package-release (linux-x86_64, ubuntu-latest, , , ) (push) Canceled after 0s
ci / package-release (macos-aarch64, macos-14, , , ) (push) Canceled after 0s
ci / package-release (macos-x86_64, macos-13, , , ) (push) Canceled after 0s
ci / package-release (windows-aarch64, windows-latest, aarch64, windows, aarch64-pc-windows-msvc) (push) Canceled after 0s
ci / package-release (windows-x86_64, windows-latest, , , ) (push) Canceled after 0s
ci / remote-bench (push) Canceled after 0s
ci / publish-gitea-release (push) Canceled after 0s
This commit is contained in:
+25
-3
@@ -10552,10 +10552,23 @@ fn windows_vt_output_mode(mode: u32) -> u32 {
|
||||
|
||||
#[cfg_attr(not(any(test, windows)), allow(dead_code))]
|
||||
fn windows_vt_input_mode(mode: u32) -> u32 {
|
||||
const ENABLE_PROCESSED_INPUT: u32 = 0x0001;
|
||||
const ENABLE_LINE_INPUT: u32 = 0x0002;
|
||||
const ENABLE_ECHO_INPUT: u32 = 0x0004;
|
||||
const ENABLE_WINDOW_INPUT: u32 = 0x0008;
|
||||
const ENABLE_MOUSE_INPUT: u32 = 0x0010;
|
||||
const ENABLE_INSERT_MODE: u32 = 0x0020;
|
||||
const ENABLE_QUICK_EDIT_MODE: u32 = 0x0040;
|
||||
const ENABLE_EXTENDED_FLAGS: u32 = 0x0080;
|
||||
const ENABLE_VIRTUAL_TERMINAL_INPUT: u32 = 0x0200;
|
||||
(mode | ENABLE_EXTENDED_FLAGS | ENABLE_VIRTUAL_TERMINAL_INPUT) & !ENABLE_QUICK_EDIT_MODE
|
||||
(mode | ENABLE_EXTENDED_FLAGS | ENABLE_VIRTUAL_TERMINAL_INPUT)
|
||||
& !(ENABLE_PROCESSED_INPUT
|
||||
| ENABLE_LINE_INPUT
|
||||
| ENABLE_ECHO_INPUT
|
||||
| ENABLE_WINDOW_INPUT
|
||||
| ENABLE_MOUSE_INPUT
|
||||
| ENABLE_INSERT_MODE
|
||||
| ENABLE_QUICK_EDIT_MODE)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
@@ -10894,13 +10907,22 @@ mod tests {
|
||||
#[test]
|
||||
fn windows_vt_input_mode_enables_escape_sequence_input() {
|
||||
assert_eq!(windows_vt_input_mode(0), 0x0280);
|
||||
assert_eq!(windows_vt_input_mode(0x0001), 0x0281);
|
||||
assert_eq!(windows_vt_input_mode(0x0201), 0x0281);
|
||||
assert_eq!(
|
||||
windows_vt_input_mode(0x0001),
|
||||
0x0280,
|
||||
"Ctrl-C and other control bytes must pass through to the remote terminal"
|
||||
);
|
||||
assert_eq!(windows_vt_input_mode(0x0201), 0x0280);
|
||||
assert_eq!(
|
||||
windows_vt_input_mode(0x0040),
|
||||
0x0280,
|
||||
"QuickEdit must be disabled so local selection cannot freeze Dosh input"
|
||||
);
|
||||
assert_eq!(
|
||||
windows_vt_input_mode(0x007f),
|
||||
0x0280,
|
||||
"line, echo, local mouse, insert, and window input modes must stay off"
|
||||
);
|
||||
assert_eq!(windows_vt_input_mode(0x00c0), 0x0280);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user