ソースを参照

Merge pull request #16 from silenceper/bugfix-menu-url

json 生成不转义 &,<,<
silenceper 8 年 前
コミット
980aba5795
1 ファイル変更5 行追加0 行削除
  1. 5 0
      util/http.go

+ 5 - 0
util/http.go

@@ -31,6 +31,11 @@ func PostJSON(uri string, obj interface{}) ([]byte, error) {
 	if err != nil {
 		return nil, err
 	}
+
+	jsonData = bytes.Replace(jsonData, []byte("\\u003c"), []byte("<"), -1)
+	jsonData = bytes.Replace(jsonData, []byte("\\u003e"), []byte(">"), -1)
+	jsonData = bytes.Replace(jsonData, []byte("\\u0026"), []byte("&"), -1)
+
 	body := bytes.NewBuffer(jsonData)
 	response, err := http.Post(uri, "application/json;charset=utf-8", body)
 	if err != nil {