From f08a9595452f4bb9662d372c903a9c68b30eb351 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Sun, 17 Nov 2024 17:49:15 +1300 Subject: [PATCH] Bugfix: Fix external CSS stylesheet loading in HTML preview (#388) --- server/ui-src/components/message/Message.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/ui-src/components/message/Message.vue b/server/ui-src/components/message/Message.vue index 6794f0a..a233c51 100644 --- a/server/ui-src/components/message/Message.vue +++ b/server/ui-src/components/message/Message.vue @@ -78,8 +78,9 @@ export default { // remove bad HTML, JavaScript, iframes etc sanitizedHTML() { + // set target & rel on all links DOMPurify.addHook('afterSanitizeAttributes', (node) => { - if (node.hasAttribute('href') && node.getAttribute('href').substring(0, 1) == '#') { + if (node.tagName != 'A' || (node.hasAttribute('href') && node.getAttribute('href').substring(0, 1) == '#')) { return } if ('target' in node) { @@ -115,7 +116,7 @@ export default { 'vertical-align', 'vlink', 'vspace', - 'xml:lang' + 'xml:lang', ], FORBID_ATTR: ['script'], }