-
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
Problem
Currently, html-dom-parser unsafely assigns strings to innerHtml. Browsers now support a method for developers to assert that any innerHtml has been sanitized and is safe to assign to innerHtml, in the form of TrustedTypes. See documentation here:
Suggested Solution
I can think of 2 ways to fix this:
- Allow the user to pass in a TrustedHTML object instead of a string. This would mean that the caller of html-dom-parser would do the sanitization, and then pass in a safe string into html-dom-parser.
- This strategy requires relaxing the check for
typeof "string"here in the code. However, we would also need to avoid any re-assigning of the html string, removing instances like this, which would make special character escapes hard to handle.
- This strategy requires relaxing the check for
- Allow the user to pass in a TrustedTypePolicy, and then
html-dom-parserwould runpolicy.createHtml(myString)before assigning anything toinnerHtml.
Keywords
security, trustedtypes, innerhtml