mirror of
https://github.com/golang/go
synced 2024-11-21 23:54:40 -07:00
encoding/xml: fix decoding of xml.Name with sub-elements
R=golang-dev, adg CC=golang-dev https://golang.org/cl/5569090
This commit is contained in:
parent
ff8133d42e
commit
9c497443ae
@ -532,6 +532,11 @@ var marshalTests = []struct {
|
|||||||
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
|
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
|
||||||
ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`,
|
ExpectXML: `<NameInField><foo xmlns="ns"></foo></NameInField>`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Value: &NameInField{Name{Space: "ns", Local: "foo"}},
|
||||||
|
ExpectXML: `<NameInField><foo xmlns="ns"><ignore></ignore></foo></NameInField>`,
|
||||||
|
UnmarshalOnly: true,
|
||||||
|
},
|
||||||
|
|
||||||
// Marshaling zero xml.Name uses the tag or field name.
|
// Marshaling zero xml.Name uses the tag or field name.
|
||||||
{
|
{
|
||||||
|
@ -265,12 +265,13 @@ func (p *Decoder) unmarshal(val reflect.Value, start *StartElement) error {
|
|||||||
saveData = v
|
saveData = v
|
||||||
|
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
sv = v
|
typ := v.Type()
|
||||||
typ := sv.Type()
|
|
||||||
if typ == nameType {
|
if typ == nameType {
|
||||||
v.Set(reflect.ValueOf(start.Name))
|
v.Set(reflect.ValueOf(start.Name))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sv = v
|
||||||
tinfo, err = getTypeInfo(typ)
|
tinfo, err = getTypeInfo(typ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user