Skip to content

Commit

Permalink
Detect html nicks in RemoteNickFormat (matrix). Fixes #696
Browse files Browse the repository at this point in the history
  • Loading branch information
42wim committed Feb 16, 2019
1 parent 99d71c2 commit 8690d50
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bridge/matrix/matrix.go
Expand Up @@ -20,11 +20,13 @@ type Bmatrix struct {
UserID string
RoomMap map[string]string
sync.RWMutex
htmlTag *regexp.Regexp
*bridge.Config
}

func New(cfg *bridge.Config) bridge.Bridger {
b := &Bmatrix{Config: cfg}
b.htmlTag = regexp.MustCompile("</.*?>")
b.RoomMap = make(map[string]string)
return b
}
Expand Down Expand Up @@ -122,8 +124,13 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
return resp.EventID, err
}

username := html.EscapeString(msg.Username)
// check if we have a </tag>. if we have, we don't escape HTML. #696
if b.htmlTag.MatchString(msg.Username) {
username = msg.Username
}
// Post normal message with HTML support (eg riot.im)
resp, err := b.mc.SendHTML(channel, msg.Username+msg.Text, html.EscapeString(msg.Username)+helper.ParseMarkdown(msg.Text))
resp, err := b.mc.SendHTML(channel, msg.Username+msg.Text, username+helper.ParseMarkdown(msg.Text))
if err != nil {
return "", err
}
Expand Down

0 comments on commit 8690d50

Please sign in to comment.