From 3e4f4a3a80a6bbe0f8983f44aff03f94657dbcfa Mon Sep 17 00:00:00 2001 From: sshikaree Date: Sat, 11 Nov 2017 20:56:39 +0300 Subject: [PATCH] Move to xml.Escape() --- xmpp.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/xmpp.go b/xmpp.go index 6af9a3e..ff8f953 100644 --- a/xmpp.go +++ b/xmpp.go @@ -901,24 +901,10 @@ func next(p *xml.Decoder) (xml.Name, interface{}, error) { return se.Name, nv, err } -var xmlSpecial = map[byte]string{ - '<': "<", - '>': ">", - '"': """, - '\'': "'", - '&': "&", -} - func xmlEscape(s string) string { var b bytes.Buffer - for i := 0; i < len(s); i++ { - c := s[i] - if s, ok := xmlSpecial[c]; ok { - b.WriteString(s) - } else { - b.WriteByte(c) - } - } + xml.Escape(&b, []byte(s)) + return b.String() }