encoding/xml: Decoder does not decode innerxml when using a TokenReader #39645
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?1.14.4
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
When using
encoding/xml.NewTokenDecoder
, the decoder fails to fill fields marked",innerxml"
.Here's an example: https://play.golang.org/p/57xVMNiafsB
Removing the second assignment to the decoder gives the desired output.
What did you expect to see?
The inner XML of the test element
What did you see instead?
empty string
Diagnosis
I've debugged this a bit and I'm fairly certain that the problem is that the "innerxml" feature relies on the internal
saved
state of theDecoder
which is not updated when using aTokenReader
. The solution would be to serialize the resulting token into thesaved
field in theDecoder.rawToken
function.The text was updated successfully, but these errors were encountered: