Do not repeat xmlns in attributes on parsing

disco_info_form
Mickael Remond 6 years ago
parent dade3504f0
commit c821267928
No known key found for this signature in database
GPG Key ID: E6F6045D79965AA3

@ -166,7 +166,13 @@ type Node struct {
}
func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
n.Attrs = start.Attr
// Assign "n.Attrs = start.Attr", without repeating xmlns in attributes
for _, attr := range start.Attr {
// Do not repeat xmlns
if attr.Name.Local != "xmlns" {
n.Attrs = append(n.Attrs, attr)
}
}
type node Node
return d.DecodeElement((*node)(n), &start)
}

@ -37,6 +37,7 @@ func TestGenerateIq(t *testing.T) {
},
Nodes: []Node{
{XMLName: xml.Name{
Space: "http://jabber.org/protocol/disco#info",
Local: "identity",
},
Attrs: []xml.Attr{

Loading…
Cancel
Save