From f6441a9b4c53fd24eb4e5f624b60badcaeeebaf3 Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 2 Aug 2023 16:21:34 +0900 Subject: [PATCH] =?UTF-8?q?html=20escape=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wshandler/room.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wshandler/room.go b/wshandler/room.go index 786793d..c26bbf0 100644 --- a/wshandler/room.go +++ b/wshandler/room.go @@ -1,6 +1,7 @@ package wshandler import ( + "bytes" "context" "encoding/json" @@ -84,13 +85,17 @@ func (r *room) loop(ctx context.Context, conns *map[string]*wsconn) (normalEnd b Body: msg.Body, Tag: append(msg.Tag, tag), } - bt, _ := json.Marshal(ds) + + buff := new(bytes.Buffer) + enc := json.NewEncoder(buff) + enc.SetEscapeHTML(false) + enc.Encode(ds) for _, conn := range *conns { r.sendMsgChan <- send_msg_queue_elem{ to: conn, mt: websocket.TextMessage, - msg: bt, + msg: buff.Bytes(), } } }