Skip to content

Commit dc82672

Browse files
committed
fix(telegram): align markdown v1 bracket escaping
Purpose of the change: - Align apprise-go Telegram Markdown v1 rendering with the upstream Python backport and live Telegram client behavior. How behavior was before: - Markdown v1 text escaped literal '[' characters. - Telegram accepted the payload but displayed the backslash in client output. Why that was a problem: - Cross-testing against the Python backport and a live Telegram client showed visible bracket escapes in Markdown v1 labels. What the new change accomplishes: - Stops escaping literal '[' characters in Telegram Markdown v1 text. - Keeps MarkdownV2 escaping unchanged. How it works: - Removes '[' from the Markdown v1 text replacer. - Adds a regression test asserting literal brackets remain visible without backslashes.
1 parent 653d524 commit dc82672

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

internal/notify/telegram_format_convert.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ func escapeTelegramMarkdownText(value, markdownMode string) string {
344344
"*", "\\*",
345345
"_", "\\_",
346346
"`", "\\`",
347-
"[", "\\[",
348347
)
349348
return replacer.Replace(value)
350349
}

internal/notify/telegram_format_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ func TestTelegramConvertsStandardMarkdownToMarkdownV1(t *testing.T) {
2828
}
2929
}
3030

31+
func TestTelegramMarkdownV1DoesNotEscapeLiteralBrackets(t *testing.T) {
32+
payload := captureTelegramPayload(t, "tgram://123456:abcdef/7890/?format=markdown&mdv=v1", "**[status]**", "", "markdown")
33+
34+
if payload["parse_mode"] != "MARKDOWN" {
35+
t.Fatalf("expected MARKDOWN parse mode, got %#v", payload["parse_mode"])
36+
}
37+
if payload["text"] != "*[status]*" {
38+
t.Fatalf("expected Telegram markdown body without visible bracket escapes, got %#v", payload["text"])
39+
}
40+
}
41+
3142
func TestTelegramConvertsStandardMarkdownToMarkdownV2(t *testing.T) {
3243
payload := captureTelegramPayload(t, "tgram://123456:abcdef/7890/?format=markdown&mdv=v2", "~~Strike~~ **Bold** _Italics_ Text", "", "markdown")
3344

0 commit comments

Comments
 (0)