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

Disable useless HTML escaping when marshaling JSON #2581

Closed
magnusbaeck opened this issue Sep 19, 2016 · 5 comments
Closed

Disable useless HTML escaping when marshaling JSON #2581

magnusbaeck opened this issue Sep 19, 2016 · 5 comments

Comments

@magnusbaeck
Copy link
Contributor

Go's HTML marshaler escapes ampersand and angle brackets by default, i.e.

{"message": "<b>hello world</b>"}

becomes this:

{"message": "\u003cb\u003ehello world\u003c/b\u003e"}

This is done to keep browsers from interpreting the JSON text as HTML, but that's hardly useful in the Beats case. Go 1.7 introduced an option to disable this kind of escaping (see json.Encoder.SetEscapeHTML), and now that Beats has switched to Go 1.7 we might as well disable this behavior. This should have a marginally positive performance impact and could decrease the payload size at least when compression is disabled.

See also https://discuss.elastic.co/t/beats-encodes-angle-brackets-and-as-u003c-and-u003e-in-json-output/60667.

@christiangalsterer
Copy link
Contributor

+1

@ruflin
Copy link
Member

ruflin commented May 9, 2017

Anyone wants to open a PR for it? :-D

ruflin added a commit to ruflin/beats that referenced this issue May 23, 2017
By default the golang JSON Marshaller escapes HTML entries. As this is not required for beats this is disabling this option.

* Unification of json marshalling

Closes elastic#2581
@nanne007
Copy link

+1

@andrewkroh
Copy link
Member

Here's another Discuss issue where this led to confusion. https://discuss.elastic.co/t/filebeat-character-encoding-problem/136486

@monkkitarp
Copy link

+1 (data integrity)

@urso urso mentioned this issue Jun 27, 2018
@ph ph closed this as completed in #7445 Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants