1
0
Fork 0

Replace URL namespace in an ugly way to avoid unmarshal error

This commit is contained in:
Chteufleur 2016-07-18 18:18:18 +02:00
parent 934c81ee39
commit 5b2aa0c077
2 changed files with 11 additions and 5 deletions

View File

@ -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"`
}

View File

@ -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)