From 00b90c36b34f560ff9217d4547600f70a5b50591 Mon Sep 17 00:00:00 2001 From: kenkaiii Date: Tue, 24 Nov 2026 03:34:47 +0800 Subject: [PATCH 1/3] Panel: check the page name where the page is called (CodeQL #8) --- showcase/panel/panel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/showcase/panel/panel.js b/showcase/panel/panel.js index fc265415..a0c05934 100644 --- a/showcase/panel/panel.js +++ b/showcase/panel/panel.js @@ -1125,11 +1125,13 @@ const scroll = $('pane-' + tab).closest('.body').scrollTop; head(); const pane = $(`pane-${tab}`); - if (!Object.hasOwn(PANES, tab)) tab = 'home'; // show() only sets page names; this keeps PANES[tab] one of them const same = render.tab === tab; render.tab = tab; const before = new Set([...pane.querySelectorAll('[data-anim]')].filter(shown).map((n) => n.dataset.anim)); // A page with a list fits it to the room left and pages it; any other page scrolls. - const draw = () => { pane.replaceChildren(...PANES[tab]().flat().filter(Boolean)); + // show() only ever sets a page name; checked here too, where the page is called. + let page = PANES.home; + if (Object.prototype.hasOwnProperty.call(PANES, tab) && typeof PANES[tab] === 'function') page = PANES[tab]; + const draw = () => { pane.replaceChildren(...page().flat().filter(Boolean)); pane.classList.toggle('paged', !!pane.querySelector('.pagebox')); keepGone(); }; draw(); // Lists show as many rows as fit: drawn once to measure, again if a different number fits. From fb8b7b61e3e66c133a37a085a948459ed6156ae8 Mon Sep 17 00:00:00 2001 From: kenkaiii Date: Tue, 24 Nov 2026 03:45:47 +0800 Subject: [PATCH 2/3] Panel: look pages up in a Map, so a tab name can't reach built-in methods (CodeQL #8) --- showcase/panel/panel.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/showcase/panel/panel.js b/showcase/panel/panel.js index a0c05934..6ef36a5e 100644 --- a/showcase/panel/panel.js +++ b/showcase/panel/panel.js @@ -1113,6 +1113,8 @@ // ---------------------------------------------------------------- render const PANES = { home, memory, abilities: abilitiesPage, model: modelPage, appearance: appearancePage, speaking: speakingPage, listening: listeningPage, shortcuts: shortcutsPage, general: generalPage, about: aboutPage, whatsnew: whatsNewPage }; + // Pages by tab name, in a Map so no name can reach an object's built-in methods. + const PAGES = new Map(Object.entries(PANES)); // focusKey: what to focus after (a data-k, or an element id); otherwise whatever had focus keeps it. function render(focusKey, animate = false) { if (!state) return; @@ -1128,9 +1130,7 @@ const same = render.tab === tab; render.tab = tab; const before = new Set([...pane.querySelectorAll('[data-anim]')].filter(shown).map((n) => n.dataset.anim)); // A page with a list fits it to the room left and pages it; any other page scrolls. - // show() only ever sets a page name; checked here too, where the page is called. - let page = PANES.home; - if (Object.prototype.hasOwnProperty.call(PANES, tab) && typeof PANES[tab] === 'function') page = PANES[tab]; + const page = PAGES.get(tab) ?? PAGES.get('home'); const draw = () => { pane.replaceChildren(...page().flat().filter(Boolean)); pane.classList.toggle('paged', !!pane.querySelector('.pagebox')); keepGone(); }; draw(); From d64d7c4153cb1efbe550eeff3fa74e09d46ec8c1 Mon Sep 17 00:00:00 2001 From: kenkaiii Date: Tue, 24 Nov 2026 03:56:43 +0800 Subject: [PATCH 3/3] Panel: call a page only once it's known to be a function (CodeQL #8) --- showcase/panel/panel.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/showcase/panel/panel.js b/showcase/panel/panel.js index 6ef36a5e..a258cfb9 100644 --- a/showcase/panel/panel.js +++ b/showcase/panel/panel.js @@ -1130,7 +1130,8 @@ const same = render.tab === tab; render.tab = tab; const before = new Set([...pane.querySelectorAll('[data-anim]')].filter(shown).map((n) => n.dataset.anim)); // A page with a list fits it to the room left and pages it; any other page scrolls. - const page = PAGES.get(tab) ?? PAGES.get('home'); + const found = PAGES.get(tab); + const page = typeof found === 'function' ? found : home; const draw = () => { pane.replaceChildren(...page().flat().filter(Boolean)); pane.classList.toggle('paged', !!pane.querySelector('.pagebox')); keepGone(); }; draw();