From c4c1ecfc7b36c8a6daf16ce0bac2812e1506dc14 Mon Sep 17 00:00:00 2001 From: Meisam <39205857+MFTabriz@users.noreply.github.com> Date: Fri, 23 Jul 2021 07:22:33 +0200 Subject: [PATCH] Allow alt and title tags in chat emojis (#1241) * allow alt and title on chat imgs * enforce non-empty alt&title tags for emojis --- core/chat/events/events.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/chat/events/events.go b/core/chat/events/events.go index 1fb998060..a66f44477 100644 --- a/core/chat/events/events.go +++ b/core/chat/events/events.go @@ -139,7 +139,8 @@ func sanitize(raw string) string { p.AllowElements("br", "p") // Allow img tags from the the local emoji directory only - p.AllowAttrs("src", "alt", "class", "title").Matching(regexp.MustCompile(`(?i)/img/emoji`)).OnElements("img") + p.AllowAttrs("src").Matching(regexp.MustCompile(`(?i)/img/emoji`)).OnElements("img") + p.AllowAttrs("alt", "title").Matching(regexp.MustCompile(`:\S+:`)).OnElements("img") p.AllowAttrs("class").OnElements("img") // Allow bold