From 5b2aa0c077dff6d20d1faa56c8be4c9ab97b9b27 Mon Sep 17 00:00:00 2001 From: Chteufleur Date: Mon, 18 Jul 2016 18:18:18 +0200 Subject: [PATCH] Replace URL namespace in an ugly way to avoid unmarshal error --- src/xmpp/httpAuth.go | 9 ++++----- src/xmpp/stream.go | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/xmpp/httpAuth.go b/src/xmpp/httpAuth.go index 0e53ef6..0f9b21f 100644 --- a/src/xmpp/httpAuth.go +++ b/src/xmpp/httpAuth.go @@ -8,11 +8,10 @@ const ( NSHTTPAuth = "http://jabber.org/protocol/http-auth" ) - // XEP-0070: Verifying HTTP Requests via XMPP type Confirm struct { - XMLName xml.Name `xml:"http://jabber.org/protocol/http-auth confirm"` - Id string `xml:"id,attr"` - Method string `xml:"method,attr"` - URL string `xml:"url,attr"` + XMLName xml.Name `xml:"http://jabber.org/protocol/http-auth confirm"` + Id string `xml:"id,attr"` + Method string `xml:"method,attr"` + URL string `xml:"url,attr"` } diff --git a/src/xmpp/stream.go b/src/xmpp/stream.go index 0919ed3..31bc7f2 100644 --- a/src/xmpp/stream.go +++ b/src/xmpp/stream.go @@ -163,6 +163,13 @@ func nextStartElement(dec *xml.Decoder) (*xml.StartElement, error) { } switch e := t.(type) { case xml.StartElement: + for i, _ := range e.Attr { + // Replace URL namespace to xml in order to avoid error on Unmarshal + // It's quite ugly, but working for now + if e.Attr[i].Name.Space == "http://www.w3.org/XML/1998/namespace" { + e.Attr[i].Name.Space = "xml" + } + } return &e, nil case xml.EndElement: log.Printf("EOF due to %s\n", e.Name)