feat(security): add Trusted Types support#4816
Conversation
This change makes Quill compatible with strict Trusted Types environments by optionally using a Trusted Types Policy when available.
Replacing innerHTML = '' with textContent = '' is faster and avoids unnecessary HTML parsing/conformance triggers.
…TML usages Introduced a shared html utility for Trusted Types and replaced verbose innerHTML assignments in UI components with setTrustedInnerHtml.
Replaced direct setAttribute('href', ...) with setAnchorHref from safevalues/dom to improve security compliance.
Replaced direct setAttribute('src', ...) with setElementAttribute from safevalues/dom to improve security compliance.
Replaced custom Trusted Types helpers with standard safevalues sanitizers for IconPicker, ColorPicker, Picker, and BaseTheme.
f44a3a1 to
754fd7f
Compare
|
Review (via AI-assisted code review): REQUEST CHANGES The direction (Trusted Types compatibility, dropping custom URL munging in favor of
Also minor: Branch is based on current main; the video iframe caveat is acknowledged and reasonable. No CI has run on this fork head yet. |
This PR adds Trusted Types support to Quill to make it easier to run in strict security environments.
Changes:
innerHTMLandparseFromStringviolations.safevaluesfor sanitizing links and images instead of custom stuff.htmlSafeByReviewfor the built-in SVG icons so they don't get stripped but stay secure.innerHTML = ''usages.Caveats:
Videoformat (iframe.src) is not updated to usesafevaluesas it requiresTrustedResourceUrlwhich is difficult to apply generically without knowing the specific domains beforehand. It continues to use standardsetAttributewith existing sanitization.Passes existing tests.