This commit is contained in:
Artem Tsyrulnikov
2026-01-19 12:50:36 +03:00
parent 62e8f98429
commit 5473b26787
17 changed files with 478 additions and 599 deletions

View File

@@ -2,6 +2,7 @@ package ui
import (
"fmt"
"regexp"
"sort"
"strings"
@@ -203,7 +204,7 @@ func FormatMessageHTML(message *echotron.Message) string {
}
}
return normalizeHTMLTags(result.String())
return normalizeInviteLinkTags(normalizeHTMLTags(result.String()))
}
// isInviteLink detects Telegram invite links used in creatives.
@@ -290,6 +291,15 @@ func normalizeHTMLTags(input string) string {
return out.String()
}
func normalizeInviteLinkTags(input string) string {
if input == "" {
return input
}
re := regexp.MustCompile(`<a\s+class="tg-link">\s*https?://t\.me/(?:\+|joinchat/)[a-zA-Z0-9_-]+\s*</a>`)
return re.ReplaceAllString(input, `<a class="tg-link"></a>`)
}
// EscapeHTML escapes HTML special characters for safe output.
func EscapeHTML(s string) string {
s = strings.ReplaceAll(s, "&", "&amp;")