Browse Source

Add string quote func

Athurg Feng 6 years ago
parent
commit
70b23ab73b
1 changed files with 3 additions and 2 deletions
  1. 3 2
      pkg/services/alerting/notifiers/dingding.go

+ 3 - 2
pkg/services/alerting/notifiers/dingding.go

@@ -3,6 +3,7 @@ package notifiers
 import (
 import (
 	"fmt"
 	"fmt"
 	"net/url"
 	"net/url"
+	"strings"
 
 
 	"github.com/grafana/grafana/pkg/bus"
 	"github.com/grafana/grafana/pkg/bus"
 	"github.com/grafana/grafana/pkg/components/simplejson"
 	"github.com/grafana/grafana/pkg/components/simplejson"
@@ -99,8 +100,8 @@ func (this *DingDingNotifier) Notify(evalContext *alerting.EvalContext) error {
 		bodyStr = `{
 		bodyStr = `{
 			"msgtype": "actionCard",
 			"msgtype": "actionCard",
 			"actionCard": {
 			"actionCard": {
-				"text": "` + message + `",
-				"title": "` + title + `",
+				"text": "` + strings.Replace(message, `"`, "'", -1) + `",
+				"title": "` + strings.Replace(title, `"`, "'", -1) + `",
 				"singleTitle": "More",
 				"singleTitle": "More",
 				"singleURL": "` + messageUrl + `"
 				"singleURL": "` + messageUrl + `"
 			}
 			}