From 2c58cb36f971aed484e880769eb2b0a21654459a Mon Sep 17 00:00:00 2001 From: Eric Lagergren Date: Sat, 20 Aug 2016 15:46:06 -0700 Subject: encoding/xml: do not ignore error return from copyValue The error return from copyValue was ignored causing some XML attribute parsing to swallow an error. Additionally, type MyMarshalerAttrTest had no UnmarshalXMLAttr method causing marshalTests not to be symmetrical and the test suite to fail for test case 101. Fixes #16158 Change-Id: Icebc505295a2c656ca4b42ba37bb0957dd7260c6 Reviewed-on: https://go-review.googlesource.com/27455 Reviewed-by: Brad Fitzpatrick --- src/encoding/xml/read.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/encoding/xml/read.go') diff --git a/src/encoding/xml/read.go b/src/encoding/xml/read.go index 937432e3a7..53c15a2840 100644 --- a/src/encoding/xml/read.go +++ b/src/encoding/xml/read.go @@ -232,7 +232,6 @@ func (p *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error { } val = val.Elem() } - if val.CanInterface() && val.Type().Implements(unmarshalerAttrType) { // This is an unmarshaler with a non-pointer receiver, // so it's likely to be incorrect, but we do what we're told. @@ -257,9 +256,7 @@ func (p *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error { return pv.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value)) } } - - copyValue(val, []byte(attr.Value)) - return nil + return copyValue(val, []byte(attr.Value)) } var ( -- cgit v1.3-6-g1900