From e4556759d8d048cd436f8ea1c1b736a206edb2ac Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Tue, 2 May 2023 07:25:09 +0200 Subject: [PATCH] Use single quotes for XML attributes. --- go.mod | 2 +- go.sum | 2 ++ httpupload.go | 1 + ox.go | 6 ++++++ stanzahandling.go | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index b1a2ba2..44f59d4 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/ProtonMail/gopenpgp/v2 v2.7.1 - github.com/beevik/etree v1.1.3 + github.com/beevik/etree v1.1.4-0.20230502040559-c04c9615d8a0 github.com/gabriel-vasile/mimetype v1.4.2 github.com/mattn/go-xmpp v0.0.0-20230302152058-9129a110df1b github.com/pborman/getopt/v2 v2.1.0 diff --git a/go.sum b/go.sum index b03bf4b..bea9eb1 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/ProtonMail/gopenpgp/v2 v2.7.1 h1:Awsg7MPc2gD3I7IFac2qE3Gdls0lZW8SzrFZ github.com/ProtonMail/gopenpgp/v2 v2.7.1/go.mod h1:/BU5gfAVwqyd8EfC3Eu7zmuhwYQpKs+cGD8M//iiaxs= github.com/beevik/etree v1.1.3 h1:RM50lzyrX4BhfIR7LI7LKq2HQtcksDWasTBnE2PaV7o= github.com/beevik/etree v1.1.3/go.mod h1:MEjUJqV1InUci5lSfeIonCXMjsMW9yC3APDqKtnyNQg= +github.com/beevik/etree v1.1.4-0.20230502040559-c04c9615d8a0 h1:YnEGLtw0qtnKiOn39YZFgOiC4NpEPMIDG32IhB9TvME= +github.com/beevik/etree v1.1.4-0.20230502040559-c04c9615d8a0/go.mod h1:MEjUJqV1InUci5lSfeIonCXMjsMW9yC3APDqKtnyNQg= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bwesterb/go-ristretto v1.2.2/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= diff --git a/httpupload.go b/httpupload.go index ef81ba4..88f922a 100644 --- a/httpupload.go +++ b/httpupload.go @@ -153,6 +153,7 @@ func httpUpload(client *xmpp.Client, iqc chan xmpp.IQ, } request := etree.NewDocument() + request.WriteSettings.AttrSingleQuote = true requestReq := request.CreateElement("request") requestReq.CreateAttr("xmlns", nsHTTPUpload) requestReq.CreateAttr("filename", fileNameEscaped) diff --git a/ox.go b/ox.go index 7bc1b5e..d6fdb52 100644 --- a/ox.go +++ b/ox.go @@ -21,6 +21,7 @@ import ( func oxDeleteNodes(jid string, client *xmpp.Client, iqc chan xmpp.IQ) error { nodeListRequest := etree.NewDocument() + nodeListRequest.WriteSettings.AttrSingleQuote = true query := nodeListRequest.CreateElement("query") query.CreateAttr("xmlns", nsDiscoItems) nlr, err := nodeListRequest.WriteToString() @@ -231,6 +232,7 @@ func oxPublishPubKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ, } pubKeyBase64 := base64.StdEncoding.EncodeToString(keySerialized) root := etree.NewDocument() + root.WriteSettings.AttrSingleQuote = true pubsub := root.CreateElement("pubsub") pubsub.CreateAttr("xmlns", nsPubsub) publish := pubsub.CreateElement("publish") @@ -278,6 +280,7 @@ func oxPublishPubKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ, return errors.New("couldn't successfully verify public key upload") } root = etree.NewDocument() + root.WriteSettings.AttrSingleQuote = true pubsub = root.CreateElement("pubsub") pubsub.CreateAttr("xmlns", nsPubsub) publish = pubsub.CreateElement("publish") @@ -481,6 +484,7 @@ func oxGenPrivKey(jid string, client *xmpp.Client, iqc chan xmpp.IQ, func oxRecvPublicKeys(client *xmpp.Client, iqc chan xmpp.IQ, recipient string, fingerprint string) (*crypto.KeyRing, error) { opkr := etree.NewDocument() + opkr.WriteSettings.AttrSingleQuote = true opkrPs := opkr.CreateElement("pubsub") opkrPs.CreateAttr("xmlns", nsPubsub) opkrPsItems := opkrPs.CreateElement("items") @@ -555,6 +559,7 @@ func oxGetPublicKeyRing(client *xmpp.Client, iqc chan xmpp.IQ, } oxPubKeyListReq := etree.NewDocument() + oxPubKeyListReq.WriteSettings.AttrSingleQuote = true oxPubKeyListReqPs := oxPubKeyListReq.CreateElement("pubsub") oxPubKeyListReqPs.CreateAttr("xmlns", nsPubsub) oxPubKeyListReqPsItems := oxPubKeyListReqPs.CreateElement("items") @@ -708,6 +713,7 @@ func oxEncrypt(client *xmpp.Client, iqc chan xmpp.IQ, oxPrivKey *crypto.Key, } } oxCryptMessage := etree.NewDocument() + oxCryptMessage.WriteSettings.AttrSingleQuote = true oxCryptMessageSc := oxCryptMessage.CreateElement("signcrypt") oxCryptMessageSc.CreateAttr("xmlns", nsOx) oxCryptMessageScTo := oxCryptMessageSc.CreateElement("to") diff --git a/stanzahandling.go b/stanzahandling.go index ed2940b..dd5c8ab 100644 --- a/stanzahandling.go +++ b/stanzahandling.go @@ -63,6 +63,7 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat) { switch xmlns.Value { case nsDiscoInfo: root := etree.NewDocument() + root.WriteSettings.AttrSingleQuote = true reply := root.CreateElement("iq") reply.CreateAttr("type", "result") reply.CreateAttr("from", client.JID()) @@ -85,6 +86,7 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat) { } default: root := etree.NewDocument() + root.WriteSettings.AttrSingleQuote = true reply := root.CreateElement("iq") reply.CreateAttr("type", "error") reply.CreateAttr("from", client.JID()) @@ -104,6 +106,7 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat) { } case "set": root := etree.NewDocument() + root.WriteSettings.AttrSingleQuote = true reply := root.CreateElement("iq") reply.CreateAttr("type", "error") reply.CreateAttr("from", client.JID())