mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/xml: don't panic when custom Unmarshaler sees StartElement
Change-Id: I90aa0a983abd0080f3de75d3340fdb15c1f9ca35 Reviewed-on: https://go-review.googlesource.com/70891 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Sam Whited <sam@samwhited.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
01c144c410
commit
be08ddbfcd
3 changed files with 27 additions and 3 deletions
|
|
@ -861,3 +861,26 @@ func TestWrapDecoder(t *testing.T) {
|
|||
t.Fatalf("Got unexpected chardata: `%s`\n", o.Chardata)
|
||||
}
|
||||
}
|
||||
|
||||
type tokReader struct{}
|
||||
|
||||
func (tokReader) Token() (Token, error) {
|
||||
return StartElement{}, nil
|
||||
}
|
||||
|
||||
type Failure struct{}
|
||||
|
||||
func (Failure) UnmarshalXML(*Decoder, StartElement) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestTokenUnmarshaler(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Error("Unexpected panic using custom token unmarshaler")
|
||||
}
|
||||
}()
|
||||
|
||||
d := NewTokenDecoder(tokReader{})
|
||||
d.Decode(&Failure{})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue