mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2026-05-24 04:43:47 -07:00
Prevent crash in avatar code (#133)
* Prevent crash on empty urn:xmpp:avatar:* nodes * Fix issue with errors * Add a test for empty avatar pubsub items
This commit is contained in:
@@ -114,3 +114,27 @@ func TestEOFError(t *testing.T) {
|
||||
t.Errorf("Recv() did not return io.EOF on end of input stream")
|
||||
}
|
||||
}
|
||||
|
||||
var emptyPubSub = strings.TrimSpace(`
|
||||
<iq xmlns="jabber:client" type='result' from='juliet@capulet.lit' id='items3'>
|
||||
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
|
||||
<items node='urn:xmpp:avatar:data'></items>
|
||||
</pubsub>
|
||||
</iq>
|
||||
`)
|
||||
func TestEmptyPubsub(t *testing.T) {
|
||||
var c Client
|
||||
c.conn = tConnect(emptyPubSub)
|
||||
c.p = xml.NewDecoder(c.conn)
|
||||
m, err := c.Recv()
|
||||
|
||||
switch m.(type) {
|
||||
case AvatarData:
|
||||
if err == nil {
|
||||
t.Errorf("Expected an error to be returned")
|
||||
}
|
||||
default:
|
||||
t.Errorf("Recv() = %v", m)
|
||||
t.Errorf("Expected a return value of AvatarData")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user