fix: sanitize daily report HTML for Telegram parse_mode

Strip div/br tags unsupported by Telegram API; reports still store UI HTML in details

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-29 16:35:04 +10:00
parent 0baeacf808
commit 2670c8cb46
4 changed files with 37 additions and 9 deletions
+2 -1
View File
@@ -198,7 +198,8 @@ def _build_report_body_rdp(host: Host, stats: dict[str, Any], when_local: dateti
def _details_from_body(body: str, stats: dict[str, Any]) -> dict[str, Any]:
escaped = html.escape(body)
report_html = '<div class="agent-report">' + escaped.replace("\n", "<br>\n") + "</div>"
# UI (Vue) допускает div; для единообразия — обёртка без br (Telegram читает через sanitize)
report_html = f'<div class="agent-report">{escaped.replace(chr(10), "<br>")}</div>'
return {
"stats": stats,
"report_body": body,