v0.2.10
RustBox CI / rustbox (push) Canceled after 0s

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-01 23:52:18 +01:00
1 parent a116890e20
commit 02d0b13ec1
24 files changed
+245 -93

No files matched your search

+15
View File
@@ -155,6 +155,21 @@
return doc.body.innerHTML;
}
function sanitizeMessagePreviewHtml(html) {
const doc = new DOMParser().parseFromString(sanitizeMessageHtml(html), "text/html");
doc.querySelectorAll("a[href]").forEach((node) => {
if (!node.hasAttribute("target")) node.setAttribute("target", "_blank");
const target = String(node.getAttribute("target") || "").toLowerCase();
if (target && !["_self", "_parent", "_top"].includes(target)) {
const rel = new Set(String(node.getAttribute("rel") || "").split(/\s+/).filter(Boolean));
rel.add("noopener");
rel.add("noreferrer");
node.setAttribute("rel", [...rel].join(" "));
}
});
return doc.body.innerHTML;
}
function sanitizeAttachmentHtml(html) {
const doc = new DOMParser().parseFromString(sanitizeMessageHtml(html), "text/html");
doc.querySelectorAll("a[href]").forEach((node) => node.removeAttribute("href"));