From 58ea1d7eb95824a9ff92d0553c5ff20ad6d583e7 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Mon, 2 Mar 2026 16:34:13 -0800 Subject: [PATCH] Be more protective around stripping at null byte, not after --- app/decoder.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/decoder.py b/app/decoder.py index e24eab9..f6ffeea 100644 --- a/app/decoder.py +++ b/app/decoder.py @@ -529,8 +529,10 @@ def decrypt_direct_message(payload: bytes, shared_secret: bytes) -> DecryptedDir message_bytes = decrypted[5:] try: message_text = message_bytes.decode("utf-8") - # Remove null terminator and any padding - message_text = message_text.rstrip("\x00") + # Truncate at first null terminator (consistent with channel message handling) + null_idx = message_text.find("\x00") + if null_idx >= 0: + message_text = message_text[:null_idx] except UnicodeDecodeError: return None