Skip to content

Use textContent instead of innerHTML when assigning script#12089

Open
shhnjk wants to merge 1 commit intofacebook:mainfrom
shhnjk:main
Open

Use textContent instead of innerHTML when assigning script#12089
shhnjk wants to merge 1 commit intofacebook:mainfrom
shhnjk:main

Conversation

@shhnjk
Copy link

@shhnjk shhnjk commented Feb 22, 2022

Currently, packages/react-error-overlay/src/index.js has a code where script is assigned using innerHTML.
This causes a problem in document under Trusted Types enforcement, because assignment to innerHTML requires TrustedHTML, but resulting html will be treated as script and therefore requires TrustedScript.

This change modifies script assignment using textContent which wouldn't require TrustedHTML, and therefore TrustedScript can be assigned (through default policy in Trusted Types).

Note: further change would be required if this library wants to be compatible with Trusted Types. However, this change only aims to allow this library to operate using default policy (which is not ideal but just a work around).

@shhnjk
Copy link
Author

shhnjk commented Mar 4, 2022

@iansu or @mrmckeb, could you PTAL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants