Skip to content

Conversation

krishnprakash
Copy link
Owner

Fixes https://github.com/krishnprakash/json-viewer/security/code-scanning/2

To fix the problem, we need to ensure that the text content is safely handled and not directly inserted into the DOM as HTML. One effective way to do this is to use textContent instead of innerHTML when creating the script element. This will prevent the browser from interpreting the text as HTML, thereby mitigating the risk of XSS.

  • Replace the use of innerHTML with textContent for the script element.
  • Ensure that the JSON data is properly escaped and handled as plain text.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Phileco <132178579+krishnprakash@users.noreply.github.com>
@krishnprakash krishnprakash marked this pull request as ready for review November 7, 2024 01:39
@krishnprakash krishnprakash merged commit 0e5a015 into master Nov 7, 2024
2 checks passed
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.

1 participant