]> Cypherpunks repositories - gostls13.git/commit
encoding/xml: EncodeToken silently eats tokens with invalid type
authorDidier Spezia <didier.06@gmail.com>
Wed, 15 Jul 2015 20:09:24 +0000 (20:09 +0000)
committerRuss Cox <rsc@golang.org>
Thu, 23 Jul 2015 14:16:01 +0000 (14:16 +0000)
commitca1d6c4b449caaada97a8024430ec572724b3ae9
tree8af9510f499f822a2b9a42181707ff2c52cd99bb
parent74ec5bf2d88364a9f29ab0468a3285e82abe5eb9
encoding/xml: EncodeToken silently eats tokens with invalid type

EncodeToken takes a Token (i.e. an interface{}) as a parameter,
and expects a value of type StartElement, EndElement, CharData,
Comment, ProcInst, or Directive.

If a pointer is passed instead, or any type which does not match
this list, the token is silently ignored.

Added a default case in the type switch to issue a proper error
when the type is invalid.

The behavior could be later improved by allowing pointers to
token to be accepted as well, but not for go1.5.

Fixes #11719

Change-Id: Ifd13c1563450b474acf66d57669fdccba76c1949
Reviewed-on: https://go-review.googlesource.com/12252
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/encoding/xml/marshal.go
src/encoding/xml/marshal_test.go