Skip to content

Commit

Permalink
Fix text to HTML conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Apr 5, 2024
1 parent 7525d06 commit 9af0d73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package main

import (
"fmt"
"html"
"io/ioutil"
"net/http"
"path"
Expand Down Expand Up @@ -87,7 +86,7 @@ func (portal *Portal) mrkdwnToMatrixHtml(mrkdwn string) string {

func (portal *Portal) renderSlackTextBlock(block slack.TextBlockObject) string {
if block.Type == slack.PlainTextType {
return html.EscapeString(html.UnescapeString(block.Text))
return event.TextToHTML(block.Text)
} else if block.Type == slack.MarkdownType {
return portal.mrkdwnToMatrixHtml(block.Text)
} else {
Expand All @@ -114,7 +113,7 @@ func (portal *Portal) renderRichTextSectionElements(elements []slack.RichTextSec
htmlText.WriteString("<code>")
}
}
htmlText.WriteString(html.EscapeString(html.UnescapeString(e.Text)))
htmlText.WriteString(event.TextToHTML(e.Text))
if e.Style != nil {
if e.Style.Code {
htmlText.WriteString("</code>")
Expand Down Expand Up @@ -153,7 +152,7 @@ func (portal *Portal) renderRichTextSectionElements(elements []slack.RichTextSec
} else {
linkText = e.URL
}
htmlText.WriteString(fmt.Sprintf(`<a href="%s">%s</a>`, e.URL, html.EscapeString(html.UnescapeString(linkText))))
htmlText.WriteString(fmt.Sprintf(`<a href="%s">%s</a>`, e.URL, event.TextToHTML(linkText)))
case *slack.RichTextSectionBroadcastElement:
htmlText.WriteString("@room")
case *slack.RichTextSectionEmojiElement:
Expand Down
1 change: 1 addition & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ func (user *User) slackMessageHandler(userTeam *database.UserTeam) {
case *slack.LatencyReport:
user.log.Debugln("latency report:", event.Value)
case *slack.MessageEvent:
user.bridge.ZLog.Trace().Any("event_content", event).Msg("Raw slack message event")
key := database.NewPortalKey(userTeam.Key.TeamID, event.Channel)
portal := user.bridge.GetPortalByID(key)
if portal != nil {
Expand Down

0 comments on commit 9af0d73

Please sign in to comment.