/** * Remove scripts and other executable markup before displaying mail HTML. * DOM-only (no broad regex) so newsletter markup is not corrupted. */ const EXECUTABLE_SELECTOR = "script, iframe, object, embed, frame, frameset, link[rel='import'], link[as='script']" const EVENT_HANDLER_ATTR = /^on/i const URI_ATTRS = /^(?:href|src|srcset|data|action|formaction|xlink:href)$/i const JAVASCRIPT_URI = /^javascript:/i function stripExecutableFromDocument(doc: Document): void { doc.querySelectorAll(EXECUTABLE_SELECTOR).forEach((el) => el.remove()) doc.querySelectorAll("svg script").forEach((el) => el.remove()) //