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

escapeJs generates invalid JSON #231

Closed
ondrejmirtes opened this issue Sep 29, 2020 · 2 comments
Closed

escapeJs generates invalid JSON #231

ondrejmirtes opened this issue Sep 29, 2020 · 2 comments

Comments

@ondrejmirtes
Copy link

Cross-posting from: nette/utils#235 (comment)

This code:

str_replace([']]>', '<!'], [']]\x3E', '\x3C!'], $json);

Needs to be:

str_replace([']]>', '<!'], ["]]\x3E", "\x3C!"], $json)

In order to produce valid JSON. Please double-check after me, but when I tried the first version, JSON.parse in the browser complained about an unexpected character because of literal \x3 in there.

@dg
Copy link
Member

dg commented Sep 29, 2020

Thanks. Fixed

@dg dg closed this as completed Sep 29, 2020
@ondrejmirtes
Copy link
Author

Thank you.

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