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 not render html #14

Open
olivierberten opened this issue Aug 16, 2022 · 2 comments
Open

How to not render html #14

olivierberten opened this issue Aug 16, 2022 · 2 comments

Comments

@olivierberten
Copy link

I'd like to use your tool with some json files containing html code. But I'd like to see the code as code rather than rendered html. Is this currently possible ?

@kodiful
Copy link

kodiful commented Aug 31, 2022

Replacing
<div class="json-value json-${r}">${t}</div>
with
<div class="json-value json-${r}">${String(t).replace('>','&gt;').replace('<','&lt;')}</div>
seems to work.

@davtur19
Copy link

davtur19 commented Sep 13, 2022

This is a serious problem of the library that does not do any kind of escape, the solution proposed by @kodiful is not a safe workaround.

Not all the necessary escapes have been made

.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;")

This bug needs to be fixed in the library and can lead to severe xss

palako added a commit to Sagittal-ai/json-view that referenced this issue Mar 8, 2024
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

3 participants