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

How to disable HTML escaping? #362

Open
mattjohnsonpint opened this issue Jul 2, 2024 · 1 comment
Open

How to disable HTML escaping? #362

mattjohnsonpint opened this issue Jul 2, 2024 · 1 comment

Comments

@mattjohnsonpint
Copy link

It seems that gjson.AppendJsonString always escapes HTML characters.

gjson/gjson.go

Lines 1943 to 1945 in c2bc5a4

} else if s[i] == '>' || s[i] == '<' || s[i] == '&' {
dst = append(dst, '\\', 'u')
dst = appendHex16(dst, uint16(s[i]))

Can we get an option to disable that for non-HTML scenarios?

There is precedent with other encoders:

Thanks.

devsergiy added a commit to wundergraph/graphql-go-tools that referenced this issue Jul 15, 2024
Fixes #839 

Note, I considered using `gjson.AppendJSONString` for better
performance, but it currently doesn't have an option to disable escaping
of HTML characters - which I think would be undesirable here. See
tidwall/gjson#362

---------

Co-authored-by: Sergiy 🇺🇦 <[email protected]>
@tidwall
Copy link
Owner

tidwall commented Jul 30, 2024

Version 1.17.3 adds the gjson.DisableEscapeHTML flag will allow for disabling HTML escaping.

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