From faf3012a36b98fed1cf74c70d148f290f37f127d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 18:17:17 +0000 Subject: [PATCH] fix: remove .expect() from strip_html_tags to pass no-panics check Use Option with graceful fallback instead of panicking on regex compilation failure. https://claude.ai/code/session_01CsP5wMZ2evEMHgGghjAfR1 --- src/agent/routine_engine.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/agent/routine_engine.rs b/src/agent/routine_engine.rs index 0f7e1a85..220e32c9 100644 --- a/src/agent/routine_engine.rs +++ b/src/agent/routine_engine.rs @@ -2004,7 +2004,7 @@ fn strip_html_tags(s: &str) -> String { // Does NOT match things like Vec, x<10, or < input.txt because those // don't have a letter immediately after '<' followed by valid tag structure, // or they aren't among recognized HTML tag names. - static HTML_TAG_RE: LazyLock = LazyLock::new(|| { + static HTML_TAG_RE: LazyLock> = LazyLock::new(|| { // Match or where tagname starts with a letter. // We restrict to known HTML tag names to avoid false positives on generic // identifiers like Vec. @@ -2017,11 +2017,13 @@ fn strip_html_tags(s: &str) -> String { section|select|slot|small|source|span|strong|style|sub|summary|sup|table|\ tbody|td|template|textarea|tfoot|th|thead|time|title|tr|track|u|ul|var|\ video|wbr"; - Regex::new(&format!(r"(?i)]*)?>", tags)) - .expect("HTML_TAG_RE is a valid static regex") + Regex::new(&format!(r"(?i)]*)?>", tags)).ok() }); - HTML_TAG_RE.replace_all(s, "").into_owned() + match HTML_TAG_RE.as_ref() { + Some(re) => re.replace_all(s, "").into_owned(), + None => s.to_string(), + } } #[cfg(test)]