From 9448419c6d840456b8acebc0f1d780e91afe56ba Mon Sep 17 00:00:00 2001 From: Chaitanya Deshpande Date: Thu, 26 Nov 2026 17:03:16 +0530 Subject: [PATCH] fix(notify): pack Telegram digests by their escaped text telegramHTML packed digest lines by their raw text, then wrote them HTML-escaped. A title or asset with <, > or & (an XSS finding, a URL with a query string) grows when escaped, so the message passed the 4096-character limit and TruncateHTML cut the last items and the footer. Those items were still reported as kept, so the notifier marked them delivered and they never reached Telegram. Measure each line as it is written: escaped, with its newline. --- notify/pack_test.go | 29 +++++++++++++++++++++++++++++ notify/telegram.go | 5 ++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/notify/pack_test.go b/notify/pack_test.go index e544481a..d59303a7 100644 --- a/notify/pack_test.go +++ b/notify/pack_test.go @@ -102,6 +102,35 @@ func TestTelegramPackingUsesRuneBudget(t *testing.T) { } } +// TestTelegramPackingCountsEscapedText covers digest lines that carry HTML +// metacharacters (an XSS title, a query string with &). They grow when escaped, +// so packing must measure the escaped text: every item reported as kept has to +// appear whole in the message, and the footer must survive. +func TestTelegramPackingCountsEscapedText(t *testing.T) { + m := batchMsg(200) + m.WindowMinutes = 60 + m.HomeURL = "https://artex.example.com/" + for i := range m.Items { + m.Items[i].Name = "Reflected XSS