From 5465605377a5fcc76fd46e0b40988f6ee4cae03c Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 12 Apr 2025 17:54:55 +0800 Subject: [PATCH] WebUI: fix dark mode in RSS entry viewer Use `allow-same-origin` sandbox directive to allow fetching the parent CSS. PR #22536. --- src/webui/www/private/views/rss.html | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/webui/www/private/views/rss.html b/src/webui/www/private/views/rss.html index 1adf741df..7088f6f8f 100644 --- a/src/webui/www/private/views/rss.html +++ b/src/webui/www/private/views/rss.html @@ -494,10 +494,18 @@ detailsView.append(divElement); } - // Place in iframe with sandbox attribute to prevent js execution - const torrentDescription = document.createRange().createContextualFragment(''); - $("rssDetailsView").append(torrentDescription); - document.getElementById("rssDescription").srcdoc = `${article.description}`; + const articleDescription = article.description; + if (articleDescription !== undefined) { + const rootColor = document.documentElement.classList.contains("dark") ? "class='dark'" : ""; + + // Place in iframe with sandbox attribute to prevent js execution + const iframeElement = document.createElement("iframe"); + iframeElement.id = "rssDescription"; + iframeElement.sandbox = "allow-same-origin"; // allowed to get parent css + iframeElement.srcdoc = `${articleDescription}`; + + detailsView.append(iframeElement); + } }; const updateRssFeedList = () => {