Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/xml: panics when trying to unmarshal a named attribute into a non-byte slice #11723

Closed
ainar-g opened this Issue Jul 15, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@ainar-g
Copy link
Contributor

ainar-g commented Jul 15, 2015

Go versions:

  • go version devel +2e4b659 Wed Jul 15 06:04:51 2015 +0000 linux/amd64
  • go version go1.4.2 linux/amd64

Code: http://play.golang.org/p/ZxYJ0EFsfv.

Expected: an error, something like unsupported type: []string.

Got: panic: reflect.Value.SetBytes of non-byte slice. Same with []int or any other non-byte slice.

May be related to #6341.

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jul 15, 2015

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Jul 15, 2015

I think we just need to change copyValue in encoding/xml/read.go to check the element type of the slice before calling SetBytes.

@andrestc

This comment has been minimized.

Copy link
Contributor

andrestc commented Jul 18, 2017

Instead of panicking, running the code on http://play.golang.org/p/ZxYJ0EFsfv returns:

main.Foo{Type:[]string{"Bar"}}

Should we consider the issue fixed?

@ainar-g

This comment has been minimized.

Copy link
Contributor Author

ainar-g commented Aug 23, 2017

@ianlancetaylor This seems fixed. Should I close the issue? Or should someone first check, if the case is covered in tests?

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Aug 23, 2017

I think this was probably fixed by https://golang.org/cl/30946, which has test cases, so, closing.

@golang golang locked and limited conversation to collaborators Aug 23, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.