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

fix: change .innerHTML to .textContent for CSP compliance #111

Merged
merged 1 commit into from Nov 8, 2023

Conversation

ghiscoding
Copy link
Contributor

@ghiscoding ghiscoding commented Nov 7, 2023

I think we should use textContent to reduce CSP (Content Security Policy) requirements. If we add CSP require-trusted-types-for 'script', then it blocks innerHTML unless it's TrustedHTML (as can be seen in this MDN article), however in the case of this lib's usage, we can simply replace the innerHTML with textContent which has the exact same effect and is CSP compliant

For reference, you can see this PR on the Vite project, they've done the exact same code change.

I think we should use `textContent` to reduce CSP (Content  Security Policy) requirements. If we add CSP `require-trusted-types-for 'script'`, then it blocks `innerHTML` unless it's `TrustedHTML`, however in the case of this lib's usage, we can simply replace the `innerHTML` with `textContent` which has the exact same effect and is more CSP compliant

For reference, you can see this [PR](vitejs/vite#10801) on the Vite project, they've done the exact same code change.
@kraaden kraaden merged commit 8bcaa2d into kraaden:master Nov 8, 2023
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.

None yet

2 participants