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: `,innerxml` values are not escaped. #16604

Closed
txgruppi opened this Issue Aug 4, 2016 · 6 comments

Comments

Projects
None yet
6 participants
@txgruppi
Copy link

txgruppi commented Aug 4, 2016

  1. What version of Go are you using (go version)?
go version go1.6.3 darwin/amd64
  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
  1. What did you do?
    https://play.golang.org/p/r-pLR_UIXe
  2. What did you expect to see?
<Company>Test &amp; Test</Company>
  1. What did you see instead?
<Company>Test & Test</Company>

This is causing problems for other software to parse the generated XML file.

@quentinmit quentinmit added this to the Go1.8 milestone Aug 8, 2016

@quentinmit

This comment has been minimized.

Copy link
Contributor

quentinmit commented Aug 8, 2016

The docs do say "a field with tag ",innerxml" is written verbatim, not subject to the usual marshalling procedure". I feel like we probably can't change the behavior at this point.

What made you think that ampersands would be escaped?

@txgruppi

This comment has been minimized.

Copy link
Author

txgruppi commented Aug 8, 2016

I got problems when using xmllint or parsing the file using python so I imagined it was an error.

@minux

This comment has been minimized.

Copy link
Member

minux commented Aug 9, 2016

@txgruppi

This comment has been minimized.

Copy link
Author

txgruppi commented Aug 9, 2016

I understand it, the user has to provide a valid value for the field. I'm sorry about it.

@kostya-sh

This comment has been minimized.

Copy link
Contributor

kostya-sh commented Aug 9, 2016

If you need automatic escaping you should use ,chardata: https://play.golang.org/p/nJEc61MqkK

@txgruppi

This comment has been minimized.

Copy link
Author

txgruppi commented Aug 9, 2016

@kostya-sh this is great! :)

Thanks.

@josharian josharian closed this Aug 9, 2016

@golang golang locked and limited conversation to collaborators Aug 9, 2017

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.