1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-02 18:41:42 +00:00

santize filenames

This commit is contained in:
curious-rabbit
2026-04-20 14:25:49 +02:00
parent f822bd05ce
commit 71c894e843
7 changed files with 98 additions and 18 deletions
+3 -1
View File
@@ -259,7 +259,9 @@ pub fn list_themes(
fn set_terminal_title_to(new_terminal_title: String) {
let osc_command_for_setting_terminal_title = "\x1b]0;";
let osc_end_command = "\x07";
print!("{osc_command_for_setting_terminal_title}{new_terminal_title}{osc_end_command}");
// Prevent BEL/ESC/C1 bytes in the title from terminating or nesting the OSC.
let safe_title = bat::sanitize_for_terminal(&new_terminal_title);
print!("{osc_command_for_setting_terminal_title}{safe_title}{osc_end_command}");
io::stdout().flush().unwrap();
}