Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
fix(chat): fix missing alt tags on custom emoji. Closes #3106
Gabe Kangas1bc179883490
diff --git a/core/chat/events/events.go b/core/chat/events/events.goindex 8483c642db..56a642e701 100644--- a/core/chat/events/events.go+++ b/core/chat/events/events.go@@ -125,9 +125,9 @@ func RenderMarkdown(raw string) string {}var (- _sanitizeReSrcMatch = regexp.MustCompile(`(?i)^/img/emoji/[^\.%]*.[A-Z]*$`)- _sanitizeReAltTitleMatch = regexp.MustCompile(`:\S+:`)- _sanitizeReClassMatch = regexp.MustCompile(`(?i)^(emoji)[A-Z_]*?$`)+ _sanitizeReSrcMatch = regexp.MustCompile(`(?i)^/img/emoji/[^\.%]*.[A-Z]*$`)+ _sanitizeReClassMatch = regexp.MustCompile(`(?i)^(emoji)[A-Z_]*?$`)+ _sanitizeNonEmptyMatch = regexp.MustCompile(`^.+$`))func sanitize(raw string) string {@@ -153,7 +153,7 @@ func sanitize(raw string) string {// Allow img tags from the the local emoji directory onlyp.AllowAttrs("src").Matching(_sanitizeReSrcMatch).OnElements("img")- p.AllowAttrs("alt", "title").Matching(_sanitizeReAltTitleMatch).OnElements("img")+ p.AllowAttrs("alt", "title").Matching(_sanitizeNonEmptyMatch).OnElements("img")p.AllowAttrs("class").Matching(_sanitizeReClassMatch).OnElements("img")// Allow bolddiff --git a/core/chat/messageRendering_test.go b/core/chat/messageRendering_test.goindex effa9777af..0a2895394c 100644--- a/core/chat/messageRendering_test.go+++ b/core/chat/messageRendering_test.go@@ -10,17 +10,14 @@ import (// and fully rendered HTML out of it.func TestRenderAndSanitize(t *testing.T) {messageContent := `- Test one two three! I go to http://yahoo.com and search for _sports_ and **answers**.- Here is an iframe <iframe src="http://yahoo.com"></iframe>-- ## blah blah blah- [test link](http://owncast.online)- <img class="emoji" alt="bananadance.gif" width="600px" src="/img/emoji/bananadance.gif">- <script src="http://hackers.org/hack.js"></script>- `+Test one two three! I go to http://yahoo.com and search for _sports_ and **answers**.+Here is an iframe<iframe src="http://yahoo.com"></iframe>+## blah blah blah+[test link](http://owncast.online)+<img class="emoji" src="/img/emoji/bananadance.gif">`expected := `Test one two three! I go to <a href="http://yahoo.com" rel="nofollow noreferrer noopener" target="_blank">http://yahoo.com</a> and search for <em>sports</em> and <strong>answers</strong>.-Here is an iframe+Here is an iframeblah blah blah<a href="http://owncast.online" rel="nofollow noreferrer noopener" target="_blank">test link</a><img class="emoji" src="/img/emoji/bananadance.gif">`diff --git a/web/components/chat/ChatTextField/ChatTextField.tsx b/web/components/chat/ChatTextField/ChatTextField.tsxindex f04ecc497a..865bcaba22 100644--- a/web/components/chat/ChatTextField/ChatTextField.tsx+++ b/web/components/chat/ChatTextField/ChatTextField.tsx@@ -179,7 +179,7 @@ export const ChatTextField: FC<ChatTextFieldProps> = ({ defaultText, enabled, fo// Custom emoji imagesconst onCustomEmojiSelect = (name: string, emoji: string) => {- const html = `<img src="${emoji}" alt="${name}" title=${name} class="emoji" />`;+ const html = `<img src="${emoji}" alt="${name}" title="${name}" class="emoji" />`;insertTextAtCursor(html);};diff --git a/web/components/chat/ChatTextField/EmojiPicker.tsx b/web/components/chat/ChatTextField/EmojiPicker.tsxindex c347251984..844b73e2c8 100644--- a/web/components/chat/ChatTextField/EmojiPicker.tsx+++ b/web/components/chat/ChatTextField/EmojiPicker.tsx@@ -43,7 +43,7 @@ export const EmojiPicker: FC<EmojiPickerProps> = ({ onEmojiSelect, onCustomEmoji});picker.addEventListener('emoji:select', event => {if (event.url) {- onCustomEmojiSelect(event.name, event.url);+ onCustomEmojiSelect(event.label, event.url);} else {onEmojiSelect(event.emoji);}diff --git a/web/components/chat/ChatUserMessage/ChatUserMessage.tsx b/web/components/chat/ChatUserMessage/ChatUserMessage.tsxindex 0fe581201c..8296010359 100644--- a/web/components/chat/ChatUserMessage/ChatUserMessage.tsx+++ b/web/components/chat/ChatUserMessage/ChatUserMessage.tsx@@ -81,6 +81,7 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({if (isAuthorBot) {badgeNodes.push(<BotUserBadge key="bot" userColor={displayColor} />);}+return (<divclassName={cn(