From cc64f0289a7cbab5f9f158ed80da51ef168dd5ae Mon Sep 17 00:00:00 2001 From: Gonzalo Franco Ceballos Date: Thu, 23 Jul 2026 07:58:03 -0700 Subject: [PATCH] fix(slack): add bold-text zero-width-space guard for trailing non-word chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slack's mrkdwn parser can fail to recognize the closing * of a bold span when it is immediately preceded by a non-word character (), ], }, ., :, em-dash, ...), mis-rendering the span and in reported cases truncating 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 underscore. Reapplied from #35144 by @gonzalofrancoceballos — the original patched gateway/platforms/slack.py, which was migrated to plugins/platforms/slack/adapter.py in the plugin migration. --- plugins/platforms/slack/adapter.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/platforms/slack/adapter.py b/plugins/platforms/slack/adapter.py index 6b2c0034baad..9fe10b95c339 100644 --- a/plugins/platforms/slack/adapter.py +++ b/plugins/platforms/slack/adapter.py @@ -3298,9 +3298,20 @@ class SlackAdapter(BasePlatformAdapter): ) # 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, )