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

I now have a text containing special characters like this &lt; &gt. When I open this text in jsonEditor and edit it, it becomes <> after editing. How can I resolve this? #1531

Open
xujinshuo-li opened this issue Jul 18, 2023 · 1 comment
Labels

Comments

@xujinshuo-li
Copy link

befor edit:
20230718-170731
after edit:
20230718-170752

@xujinshuo-li xujinshuo-li changed the title I now have a text containing special characters like this &lt; &gt. When I open this text in jsEditor and edit it, it becomes <> after editing. How can I resolve this? I now have a text containing special characters like this &lt; &gt. When I open this text in jsonEditor and edit it, it becomes <> after editing. How can I resolve this? Jul 18, 2023
@josdejong
Copy link
Owner

The editor escapes script tags < > into &lt; and &gt; to prevent against XSS attacks (i.e prevent loading a JSON file containing <script>...</script> to execute this script.

Code: https://github.com/josdejong/jsoneditor/blob/develop/src/js/Node.js#L4014-L4056

We could change this but we need to be careful to stay safe against XSS attacks, it will require effort and care (replacing usages of .innerHTML with .innerText, which works quite differently).

The successor of this library, svelte-jsoneditor, has solved this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants