From 7396045241cfe2ab85236504c2157b3bfdba7003 Mon Sep 17 00:00:00 2001 From: Gonzalo Franco Ceballos Date: Fri, 29 May 2026 22:34:53 -0600 Subject: [PATCH] fix(slack): broaden bold-text zero-width-space guard to all non-word chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slack's mrkdwn parser silently truncates messages when a closing * follows a non-word character — not just )]} but also ., :, —, etc. Previously only handled )]}. Now guards against any character that isn't alphanumeric or underscore. --- gateway/platforms/slack.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gateway/platforms/slack.py b/gateway/platforms/slack.py index 5accfdb410899..0879cef74d47f 100644 --- a/gateway/platforms/slack.py +++ b/gateway/platforms/slack.py @@ -1255,9 +1255,19 @@ def _convert_header(m): ) # 9) Convert bold: **text** → *text* (Slack bold) + # Slack's mrkdwn parser fails to recognize the closing * when it is + # immediately preceded by non-word characters (e.g. ), ], }, ., :, —). + # This causes the parser to silently truncate the rest of the message. + # Insert a zero-width space (U+200B) between the last character and + # the closing * whenever the last character is not alphanumeric or _. + def _convert_bold(m): + inner = m.group(1) + if inner and not (inner[-1].isalnum() or inner[-1] == '_'): + return _ph(f'*{inner}\u200b*') + return _ph(f'*{inner}*') text = re.sub( r'\*\*(.+?)\*\*', - lambda m: _ph(f'*{m.group(1)}*'), + _convert_bold, text, )