From f6a9f4592ada06b7a368f6b9875f3de2b9ee1f77 Mon Sep 17 00:00:00 2001 From: 3nd3r Date: Sun, 28 Dec 2025 16:03:42 -0600 Subject: [PATCH] Fix critical bug: Messages being stripped by over-aggressive sanitization - Bot messages containing IRC color codes were being completely stripped - sanitize_user_input() without allowed_chars was removing all formatting - Changed to only remove CR/LF from messages while preserving formatting codes - This was causing silent failures where no messages were sent to channel --- src/duckhuntbot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/duckhuntbot.py b/src/duckhuntbot.py index d5230e7..4de1d8c 100644 --- a/src/duckhuntbot.py +++ b/src/duckhuntbot.py @@ -347,7 +347,9 @@ class DuckHuntBot: # Sanitize target and message safe_target = sanitize_user_input(target, max_length=100, allowed_chars='#&+!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-[]{}^`|\\') - safe_msg = sanitize_user_input(msg, max_length=400) + # Sanitize message (preserve IRC formatting codes - only remove CR/LF) + safe_msg = msg[:400] if isinstance(msg, str) else str(msg)[:400] + safe_msg = safe_msg.replace('\r', '').replace('\n', ' ').strip() if not safe_target or not safe_msg: self.logger.warning(f"Empty target or message after sanitization")