From 5750aa2c626b8d4aa26ac387fb01827342592f87 Mon Sep 17 00:00:00 2001 From: chotaire Date: Wed, 17 Apr 2019 03:36:04 +0200 Subject: [PATCH] Strip IRC colors sent to XMPP --- bridge/xmpp/xmpp.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bridge/xmpp/xmpp.go b/bridge/xmpp/xmpp.go index 6fc573bf..585151d7 100644 --- a/bridge/xmpp/xmpp.go +++ b/bridge/xmpp/xmpp.go @@ -4,6 +4,7 @@ import ( "crypto/tls" "strings" "time" + "regexp" "github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge/config" @@ -82,6 +83,10 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) { } b.Log.Debugf("=> Receiving %#v", msg) + // Strip IRC colors sent to XMPP + re := regexp.MustCompile(`\x03(?:\d{1,2}(?:,\d{1,2})?)?|[[:cntrl:]]`) + msg.Text = re.ReplaceAllString(msg.Text, "") + // Upload a file (in xmpp case send the upload URL because xmpp has no native upload support) if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) {