Kantoor. Webmail. HtmlSanitizer
(Kantoor v1.0.0)
Turns hostile HTML mail into something that is safe to put inside the sandboxed iframe, in two layers:
- an allow-list scrub (
html_sanitize_ex, seeKantoor.Webmail.HtmlScrubber) that removes scripts, styles, forms, frames, event handlers,javascript:and other URL schemes, remote images and CSS (so nourl()beacons); - the iframe itself:
sandboxWITHOUTallow-scripts/allow-same-origin, plus a CSP meta tag (default-src 'none') in the document.
Remote content is blocked unless remote: true (a per-view toggle, never
persisted). Links get rel="noopener noreferrer nofollow" and open in a new
tab (<base target=_blank>).
Summary
Functions
True when the HTML references remote images (so the toggle is worth showing).
Sanitizes html. Options: :remote (allow remote images, default false) and
:inline (%{cid => {mime, bytes}}, embedded images to inline as data URIs).
The complete srcdoc document for the iframe, including its CSP. Remote
images are only permitted by the CSP when remote: true.
Functions
True when the HTML references remote images (so the toggle is worth showing).
Sanitizes html. Options: :remote (allow remote images, default false) and
:inline (%{cid => {mime, bytes}}, embedded images to inline as data URIs).
The complete srcdoc document for the iframe, including its CSP. Remote
images are only permitted by the CSP when remote: true.