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

Text escaping not correct #55

Closed
crazytyper opened this issue Oct 17, 2018 · 2 comments
Closed

Text escaping not correct #55

crazytyper opened this issue Oct 17, 2018 · 2 comments

Comments

@crazytyper
Copy link

The valid character range for XML is specified as:

Char := #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]

When producing XML using WriteTo a set of strings.Replacer objects in etree.go are used to escape strings.

However, these replacers fail to replace some characters that are not valid in XML (e.g. 0xB vertical tab).

This leads to invalid XML being produced.

The go standard package xml replaces invalid characters with \uFFFD (unicode replacement character) which appears to be common practice across other XML libraries.

I propose using xml.EscapeText instead of the current approach based on strings.NewReplacer(...).

@beevik
Copy link
Owner

beevik commented Oct 17, 2018

thanks for the feedback. I'll take a look at this.

@beevik
Copy link
Owner

beevik commented Oct 19, 2018

This should be fixed in 69ce3ef

Thanks for the report!

@beevik beevik closed this as completed Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants