diff options
author | Wim <wim@42.be> | 2019-02-17 21:48:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-17 21:48:32 +0100 |
commit | aeaea0574f491e61d90b2ce318c1ac26ddba2be1 (patch) | |
tree | 979e9b542fbfcfea3e17ab74cceff64146c4cb23 /bridge/matrix | |
parent | 99d71c21770cc371d38c71995dccfdd9489be7c4 (diff) | |
download | matterbridge-msglm-aeaea0574f491e61d90b2ce318c1ac26ddba2be1.tar.gz matterbridge-msglm-aeaea0574f491e61d90b2ce318c1ac26ddba2be1.tar.bz2 matterbridge-msglm-aeaea0574f491e61d90b2ce318c1ac26ddba2be1.zip |
Detect html nicks in RemoteNickFormat (matrix). Fixes #696 (#719)
Diffstat (limited to 'bridge/matrix')
-rw-r--r-- | bridge/matrix/matrix.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bridge/matrix/matrix.go b/bridge/matrix/matrix.go index e26cf238..f76c4ab8 100644 --- a/bridge/matrix/matrix.go +++ b/bridge/matrix/matrix.go @@ -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 } @@ -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 } |