From 1f7d8497e708e8c05a8736556463895dca2d8061 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Jul 2026 12:36:08 +0000 Subject: [PATCH] fix: normalize the theme-toggle's persisted localStorage value Only accept a stored slashed-home-theme value if it's one of the known states (auto/dark/light). Guards against a stale or tampered value driving an invalid data-theme attribute and a garbage toggle-button label. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_016rBJXkhpA2ZvDxsoRWFZGG --- copy-wip/github-pages-index.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/copy-wip/github-pages-index.html b/copy-wip/github-pages-index.html index 3f33a0a6..6a087c27 100644 --- a/copy-wip/github-pages-index.html +++ b/copy-wip/github-pages-index.html @@ -660,7 +660,10 @@

Developer

var btn = document.getElementById('theme-toggle'); var states = ['auto', 'dark', 'light']; var current = 'auto'; - try { current = localStorage.getItem('slashed-home-theme') || 'auto'; } catch (e) {} + try { + var stored = localStorage.getItem('slashed-home-theme'); + if (states.indexOf(stored) !== -1) current = stored; + } catch (e) {} function apply(state) { if (state === 'auto') document.documentElement.removeAttribute('data-theme'); else document.documentElement.setAttribute('data-theme', state);