1 parent
1bb398acd1
commit
1309358b68
17 files changed
+239
-50
No files matched your search
@@ -68,6 +68,7 @@
|
||||
realtimeSeenEvents: new Map(),
|
||||
realtimeNotifiedMessages: new Map(),
|
||||
realtimeNotificationSuppressions: new Map(),
|
||||
realtimeNotificationSuppressedMessages: new Map(),
|
||||
realtimeNotificationsReady: false,
|
||||
realtimeNotificationsArmRequested: false,
|
||||
realtimeNotificationsReadyTimer: null,
|
||||
@@ -166,7 +167,17 @@
|
||||
}
|
||||
|
||||
function sanitizeMessagePreviewHtml(html) {
|
||||
const doc = new DOMParser().parseFromString(sanitizeMessageHtml(html), "text/html");
|
||||
const source = stripRustBoxUiLeak(html);
|
||||
const sourceDoc = new DOMParser().parseFromString(source, "text/html");
|
||||
const headStyles = [...sourceDoc.head.querySelectorAll("style")]
|
||||
.map((node) => String(node.textContent || "").replace(/@import\s+(?:url\()?[^;]+;?/gi, ""))
|
||||
.filter((css) => css.trim());
|
||||
const doc = new DOMParser().parseFromString(sanitizeMessageHtml(source), "text/html");
|
||||
for (const css of headStyles.reverse()) {
|
||||
const style = doc.createElement("style");
|
||||
style.textContent = css;
|
||||
doc.body.prepend(style);
|
||||
}
|
||||
doc.querySelectorAll("a[href]").forEach((node) => {
|
||||
if (!node.hasAttribute("target")) node.setAttribute("target", "_blank");
|
||||
const target = String(node.getAttribute("target") || "").toLowerCase();
|
||||
|
||||
Reference in new issue
Block a user