From fb0ffd6371a436e074f83e182459d4fe4ad6ed47 Mon Sep 17 00:00:00 2001 From: Drew Hintz Date: Thu, 2 Jul 2026 23:37:59 +0000 Subject: [PATCH] simplify exec config summary sanitization --- .../src/event_processor_with_human_output.rs | 62 ++++++------------- ...event_processor_with_human_output_tests.rs | 6 +- 2 files changed, 20 insertions(+), 48 deletions(-) diff --git a/codex-rs/exec/src/event_processor_with_human_output.rs b/codex-rs/exec/src/event_processor_with_human_output.rs index 9c3839eabf..2db6456153 100644 --- a/codex-rs/exec/src/event_processor_with_human_output.rs +++ b/codex-rs/exec/src/event_processor_with_human_output.rs @@ -418,50 +418,24 @@ impl EventProcessor for EventProcessorWithHumanOutput { } fn sanitize_config_summary_value(value: &str) -> String { - let mut sanitized = String::new(); - let mut pending_space = false; - - for ch in value.chars() { - if ch.is_whitespace() { - pending_space = !sanitized.is_empty(); - continue; - } - - if is_disallowed_config_summary_char(ch) { - continue; - } - - if pending_space { - sanitized.push(' '); - pending_space = false; - } - - sanitized.push(ch); - } - - sanitized -} - -fn is_disallowed_config_summary_char(ch: char) -> bool { - if ch.is_control() { - return true; - } - - matches!( - ch, - '\u{00AD}' - | '\u{034F}' - | '\u{061C}' - | '\u{180E}' - | '\u{200B}'..='\u{200F}' - | '\u{202A}'..='\u{202E}' - | '\u{2060}'..='\u{206F}' - | '\u{FE00}'..='\u{FE0F}' - | '\u{FEFF}' - | '\u{FFF9}'..='\u{FFFB}' - | '\u{1BCA0}'..='\u{1BCA3}' - | '\u{E0100}'..='\u{E01EF}' - ) + value + .chars() + .map(|ch| { + if ch.is_control() + || matches!( + ch, + '\u{061C}' + | '\u{200E}'..='\u{200F}' + | '\u{202A}'..='\u{202E}' + | '\u{2066}'..='\u{2069}' + ) + { + '�' + } else { + ch + } + }) + .collect() } fn config_summary_entries( diff --git a/codex-rs/exec/src/event_processor_with_human_output_tests.rs b/codex-rs/exec/src/event_processor_with_human_output_tests.rs index 71ffb305f2..95df404ab3 100644 --- a/codex-rs/exec/src/event_processor_with_human_output_tests.rs +++ b/codex-rs/exec/src/event_processor_with_human_output_tests.rs @@ -178,10 +178,8 @@ fn summarizes_managed_read_only_permission_profile() { #[test] fn config_summary_values_are_single_line_terminal_text() { assert_eq!( - sanitize_config_summary_value( - " repo\t|\nWorking\x1b\u{0007}\u{009D}\u{009C} | \u{202E}T\u{2066}ext " - ), - "repo | Working | Text" + sanitize_config_summary_value("repo\nmodel: other\r\x1b[2J\u{0007}\u{202E}rtl\u{2066}"), + "repo�model: other��[2J��rtl�" ); }