Harden Windows console VT modes
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:
DuProcess
2026-07-16 22:06:19 -04:00
parent d34713b40e
commit 0102d453bd
+21 -8
View File
@@ -10541,14 +10541,20 @@ impl RawMode {
#[cfg_attr(not(any(test, windows)), allow(dead_code))]
fn windows_vt_output_mode(mode: u32) -> u32 {
const ENABLE_PROCESSED_OUTPUT: u32 = 0x0001;
const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004;
mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING
const DISABLE_NEWLINE_AUTO_RETURN: u32 = 0x0008;
mode | ENABLE_PROCESSED_OUTPUT
| ENABLE_VIRTUAL_TERMINAL_PROCESSING
| DISABLE_NEWLINE_AUTO_RETURN
}
#[cfg_attr(not(any(test, windows)), allow(dead_code))]
fn windows_vt_input_mode(mode: u32) -> u32 {
const ENABLE_QUICK_EDIT_MODE: u32 = 0x0040;
const ENABLE_EXTENDED_FLAGS: u32 = 0x0080;
const ENABLE_VIRTUAL_TERMINAL_INPUT: u32 = 0x0200;
mode | ENABLE_VIRTUAL_TERMINAL_INPUT
(mode | ENABLE_EXTENDED_FLAGS | ENABLE_VIRTUAL_TERMINAL_INPUT) & !ENABLE_QUICK_EDIT_MODE
}
#[cfg(windows)]
@@ -10878,16 +10884,23 @@ mod tests {
#[test]
fn windows_vt_output_mode_enables_ansi_sequences() {
assert_eq!(windows_vt_output_mode(0), 0x0004);
assert_eq!(windows_vt_output_mode(0x0001), 0x0005);
assert_eq!(windows_vt_output_mode(0x0005), 0x0005);
assert_eq!(windows_vt_output_mode(0), 0x000d);
assert_eq!(windows_vt_output_mode(0x0001), 0x000d);
assert_eq!(windows_vt_output_mode(0x0005), 0x000d);
assert_eq!(windows_vt_output_mode(0x000d), 0x000d);
}
#[test]
fn windows_vt_input_mode_enables_escape_sequence_input() {
assert_eq!(windows_vt_input_mode(0), 0x0200);
assert_eq!(windows_vt_input_mode(0x0001), 0x0201);
assert_eq!(windows_vt_input_mode(0x0201), 0x0201);
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(0x0040),
0x0280,
"QuickEdit must be disabled so local selection cannot freeze Dosh input"
);
assert_eq!(windows_vt_input_mode(0x00c0), 0x0280);
}
#[test]