Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
proposal: encoding/xml: Return a SyntaxError for unmatched start elements at EOF #11405
I propose to make the xml.Decoder's Token routine fail with a syntax error, when the XML input contains unmatched start elements and the end of the stream.
The xml.Decoder's Token routine returns successfully for input even if the XML content includes not properly closed start elements. For example, the following input
causes Token to return nil, io.EOF at the end of the stream, despite the unmatched "root" start element.
In my understanding Token should reject syntactically incorrect XML like this with an error.
This is also indicated by the following statement of the godoc of Token (emphasis mine)
I propose that a xml.Decoder's Token routine should return xml.SyntaxError for dangling start elements at the end of the stream. To do so, I have a CL ready for submission. Should this go through the proposed proposal process? Should this wait until Go 1.6?
Working example: http://play.golang.org/p/Fs6NPvDLu0
[edited for clarity]