From 6dca9b61b18236c93905026e1939d76990bff8e1 Mon Sep 17 00:00:00 2001 From: vickydotbat Date: Fri, 17 Jul 2026 18:17:30 +0200 Subject: [PATCH] fix: translate only static strings in unread drawer menu Translating menuEl.innerHTML re-serialized untrusted topic titles into HTML and reinjected them via innerHTML. Translate only the two static placeholder strings ([[unread:no-unread-topics]], [[unread:title]]) via a small textContent-based helper instead. --- public/client.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/public/client.js b/public/client.js index 82be8e3..a12fa26 100644 --- a/public/client.js +++ b/public/client.js @@ -159,6 +159,16 @@ }); } + function translateText(el) { + if (window.require) { + window.require(['translator'], function (translator) { + translator.translate(el.textContent, (translated) => { + el.textContent = translated; + }); + }); + } + } + function renderUnreadMenu(menuEl, topics) { if (!menuEl) { return; @@ -179,6 +189,7 @@ empty.className = 'dropdown-item disabled'; empty.textContent = '[[unread:no-unread-topics]]'; addItem(empty); + translateText(empty); } list.forEach((topic) => { @@ -204,14 +215,7 @@ seeAll.href = `${relativePath}/unread`; seeAll.textContent = '[[unread:title]]'; addItem(seeAll); - - if (window.require) { - window.require(['translator'], function (translator) { - translator.translate(menuEl.innerHTML, (translated) => { - menuEl.innerHTML = translated; - }); - }); - } + translateText(seeAll); } function getWestgateTopbar() {