The library decodes the XML into a 2-elements slice:
{ 5, nil }
I did some tests, and i discovered that, when decoding a slice, the library does not decode correctly the element immediately after an element without the type identifier. That's due to this sequence of events:
dec.decodeValue() calls dec.Token() and reads a token, expecting to find the starting tag of a type identifier (i.e. <string>), but instead it finds </value>, and returns nil, since it's an EndElement
https://github.com/kolo/xmlrpc/blob/master/decoder.go#L89
the slice decoder calls dec.Skip(), which normally should read any tag up to </value>, but since </value> has already been processed, it goes on and reads the next <value>, <string>, </string>, </value>, so the next array element is totally skipped:
https://github.com/kolo/xmlrpc/blob/master/decoder.go#L278
This patch fixes the problem, by skipping dec.Skip() when this problem arises.
I also added a unit test.
Hello, i stumbled across a response that xmlrpc is unable to decode correctly:
This is a 3-elements array containing respectively:
The library decodes the XML into a 2-elements slice:
I did some tests, and i discovered that, when decoding a slice, the library does not decode correctly the element immediately after an element without the type identifier. That's due to this sequence of events:
the slice decoder calls dec.Token() and reads a token (<value>) https://github.com/kolo/xmlrpc/blob/master/decoder.go#L248
the slice decoder calls dec.decodeValue() https://github.com/kolo/xmlrpc/blob/master/decoder.go#L266
dec.decodeValue() calls dec.Token() and reads a token, expecting to find the starting tag of a type identifier (i.e. <string>), but instead it finds </value>, and returns nil, since it's an EndElement https://github.com/kolo/xmlrpc/blob/master/decoder.go#L89
the slice decoder calls dec.Skip(), which normally should read any tag up to </value>, but since </value> has already been processed, it goes on and reads the next <value>, <string>, </string>, </value>, so the next array element is totally skipped: https://github.com/kolo/xmlrpc/blob/master/decoder.go#L278
This patch fixes the problem, by skipping dec.Skip() when this problem arises. I also added a unit test.