From e381942708b6892ca16d3375bb9fd6c4ce212118 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Tue, 9 May 2023 21:23:29 +0200 Subject: [PATCH] Use single quotes for stanzas created by beevik/etree. Squashed commit of the following: commit 8e33952869831f620fa289f1bc997128a40eaee3 Author: Martin Dosch Date: Tue May 9 21:22:40 2023 +0200 Clean go.mod commit 11bb88fca2d4bb76557e912f46f726e675e0b0cb Merge: 8d45413 b01ed4b Author: Martin Dosch Date: Tue May 9 21:21:48 2023 +0200 Merge branch 'master' into singlequotes commit 8d45413f052cd4f33f6f2010d7dde1155ddf7a0b Author: Martin Dosch Date: Tue May 2 09:39:54 2023 +0200 Add more singlequotes. :) commit c496e2596ad426e174836e3f1edd2e97f10eff8a Author: Martin Dosch Date: Tue May 2 09:35:12 2023 +0200 Use single quotes. commit e4556759d8d048cd436f8ea1c1b736a206edb2ac Author: Martin Dosch Date: Tue May 2 07:25:09 2023 +0200 Use single quotes for XML attributes. --- CHANGELOG.md | 1 + httpupload.go | 2 ++ ox.go | 8 ++++++++ stanzahandling.go | 3 +++ 4 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1740ef..76e2f43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Print `--help` output to stdout instead of stderr. - Print sent stanzas when `--debug` is used (via go-xmpp commit 9129a110df1b). - Allow JIDs without localpart. +- Use single quotes for attributes in stanzas created by github.com/beevik/etree. - Fix SRV lookup when the domain has a CNAME (via xmppsrv v0.2.5). ## [v0.5.6] 2022-11-11 diff --git a/httpupload.go b/httpupload.go index ef81ba4..a34f366 100644 --- a/httpupload.go +++ b/httpupload.go @@ -74,6 +74,7 @@ func httpUpload(client *xmpp.Client, iqc chan xmpp.IQ, for _, r := range iqDiscoItemsXMLItems { jid := r.SelectAttr("jid") iqDiscoInfoReqXML := etree.NewDocument() + iqDiscoInfoReqXML.WriteSettings.AttrSingleQuote = true iqDiscoInfoReqXMLQuery := iqDiscoInfoReqXML.CreateElement("query") iqDiscoInfoReqXMLQuery.CreateAttr("xmlns", nsDiscoInfo) iqdi, err := iqDiscoInfoReqXML.WriteToString() @@ -153,6 +154,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..22d519a 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() @@ -53,6 +54,7 @@ func oxDeleteNodes(jid string, client *xmpp.Client, continue } deleteNodeRequest := etree.NewDocument() + deleteNodeRequest.WriteSettings.AttrSingleQuote = true pubsub := deleteNodeRequest.CreateElement("pubsub") pubsub.CreateAttr("xmlns", nsPubsubOwner) delete := pubsub.CreateElement("delete") @@ -231,6 +233,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 +281,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 +485,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 +560,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 +714,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") @@ -730,6 +737,7 @@ func oxEncrypt(client *xmpp.Client, iqc chan xmpp.IQ, oxPrivKey *crypto.Key, return "error", err } om := etree.NewDocument() + om.WriteSettings.AttrSingleQuote = true omMessage := om.CreateElement("message") omMessage.CreateAttr("to", recipient) omMessage.CreateAttr("id", getID()) 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())