Skip to content

Avoid encoding html entities in JSON documents #1464

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

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

jsoriano
Copy link
Member

Avoid encoding HTML entities in JSON documents generated by tests.

The main JSON "Marshaling" helpers also encode HTML entities to reduce
the risk of injections through JSON documents embedded in HTML.
In documents generated by package tests, we want to have the raw document,
as found in Elasticsearch.

This change changes the rendering behaviour for packages starting on 2.12.0,
so these entities are not encoded.

Fix #320.

JSON encoders in Go standard library encode HTML special characters by
default, so the resulting JSON is safe to use in HTML documents.

In sample documents and test results in packages we want the raw JSON,
so we can see the actual content that would be ingested when using the
integration.
@jsoriano jsoriano requested a review from a team September 21, 2023 14:10
@jsoriano jsoriano self-assigned this Sep 21, 2023
@jsoriano
Copy link
Member Author

test integrations

@jsoriano
Copy link
Member Author

test integrations

@elasticmachine
Copy link
Collaborator

Created or updated PR in integrations repostiory to test this vesrion. Check elastic/integrations#7917

@jsoriano
Copy link
Member Author

/test

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @jsoriano

@jsoriano jsoriano marked this pull request as ready for review September 21, 2023 17:24
Copy link
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

This change changes the rendering behaviour for packages starting on 2.12.0,
so these entities are not encoded.

Ok, perfect!

@jsoriano jsoriano merged commit b483728 into elastic:main Sep 22, 2023
@jsoriano jsoriano deleted the avoid-encoding-html branch September 22, 2023 10:08
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

Successfully merging this pull request may close these issues.

Pipeline test file generation escapes special characters in golden files generation
3 participants