From 08c0194fc7513c1fb82e4b954e918547bfd4d6f3 Mon Sep 17 00:00:00 2001 From: Ray <18078751+rayjanoka@users.noreply.github.com> Date: Tue, 15 Aug 2023 22:51:05 -0600 Subject: [PATCH] letting slack-go escape the msg --- go.mod | 1 - go.sum | 6 ------ slackcat.go | 7 ++----- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 9b5b914..896c941 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/BurntSushi/toml v0.3.0 github.com/fatih/color v1.5.0 github.com/mattn/go-colorable v0.1.8 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect github.com/skratchdot/open-golang v0.0.0-20160302144031-75fb7ed4208c github.com/slack-go/slack v0.8.1 github.com/urfave/cli v1.20.0 diff --git a/go.sum b/go.sum index a3f0fb3..75f406e 100644 --- a/go.sum +++ b/go.sum @@ -8,12 +8,8 @@ github.com/go-test/deep v1.0.4 h1:u2CU3YKy9I2pmu9pX0eq50wCgjfGIt539SqR7FbHiho= github.com/go-test/deep v1.0.4/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= @@ -28,8 +24,6 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -golang.org/x/sys v0.0.0-20171123182949-a13efeb2fd21 h1:i8c2841iGqFgiUiEQFmDkl5qGkfTS0axK9pPblMoTEU= -golang.org/x/sys v0.0.0-20171123182949-a13efeb2fd21/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/slackcat.go b/slackcat.go index 4d2c09a..33ae553 100644 --- a/slackcat.go +++ b/slackcat.go @@ -11,7 +11,7 @@ import ( "github.com/slack-go/slack" ) -//Slackcat client +// Slackcat client type Slackcat struct { queue *StreamQ shutdown chan os.Signal @@ -93,11 +93,8 @@ var CurMsgTS string func (sc *Slackcat) postMsg(msglines []string) { msg := strings.Join(msglines, "\n") - msg = strings.Replace(msg, "&", "%26amp%3B", -1) - msg = strings.Replace(msg, "<", "%26lt%3B", -1) - msg = strings.Replace(msg, ">", "%26gt%3B", -1) - msgOpts := []slack.MsgOption{slack.MsgOptionText(msg, false)} + msgOpts := []slack.MsgOption{slack.MsgOptionText(msg, true)} if sc.username != "" { msgOpts = append(msgOpts, slack.MsgOptionAsUser(false)) msgOpts = append(msgOpts, slack.MsgOptionUsername(sc.username))