Skip to content

Update rendering template to avoid potential XSS attack#21

Open
kacrouse wants to merge 1 commit into
summerstyle:masterfrom
kacrouse:master
Open

Update rendering template to avoid potential XSS attack#21
kacrouse wants to merge 1 commit into
summerstyle:masterfrom
kacrouse:master

Conversation

@kacrouse

@kacrouse kacrouse commented Jun 6, 2025

Copy link
Copy Markdown

Prior to this change, HTML found in the displayed JSON key or value would be rendered. This would allow for a XSS attack if the JSON contained malicious HTML.

The fix leverages textContent to ensure any HTML is properly escaped.

Prior to this change, HTML found in the displayed JSON key or value would be rendered. This would allow for a XSS attack if the JSON contained malicious HTML.
LostInBrittany added a commit to LostInBrittany/granite-json-tree-viewer that referenced this pull request Jun 6, 2026
Full rewrite of the Polymer 2.x / Bower element as a Lit 3 element:

- Vendor summerstyle/jsonTreeViewer as an ES module in src/jsontree.js;
  the DOM is built with createElement/textContent (no innerHTML),
  fixing the XSS of summerstyle/jsonTreeViewer#21 for both simple
  and complex nodes
- Replace alert() calls with a jsontree-jsonpath event and a TypeError
- Preserve key insertion order by default (opt-in sort-keys attribute)
- Replace @apply mixins with CSS custom properties and ::part()
- Inline icons.svg as a data URI (no runtime fetching)
- npm + @web/dev-server + @web/test-runner tooling, test suite included
- Relicense from Apache-2.0 to MIT, matching the vendored library
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