From d15b712180383b692c8afd693010124067794f09 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Thu, 30 Apr 2026 16:47:11 -0300 Subject: [PATCH] fix: sanitize malformed HTML tags (remove spaces after <) --- botserver/src/core/bot/mod.rs | 46 ++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/botserver/src/core/bot/mod.rs b/botserver/src/core/bot/mod.rs index 00011f57..0697095d 100644 --- a/botserver/src/core/bot/mod.rs +++ b/botserver/src/core/bot/mod.rs @@ -886,21 +886,45 @@ let system_prompt = if !message.active_switchers.is_empty() { #[cfg(not(feature = "chat"))] let switchers: Vec = Vec::new(); + // Flush any remaining content in html_buffer + if !html_buffer.is_empty() { + let content_to_send = html_buffer + .replace("< ", "<") + .replace(""); if should_flush { - let content_to_send = html_buffer.clone(); + // Sanitize malformed tags (e.g. "< class" -> " "