fix(stats): validate max-titles against allowlist instead of positive-in

- `loadMaxTitles` now rejects values not in `MAX_TITLES_OPTIONS` (e.g. arbitrary integers like 8)
- Add test covering unsupported-but-numeric stored values
This commit is contained in:
2026-07-06 01:15:24 -07:00
parent 42433dc30b
commit 1cead99c98
3 changed files with 18 additions and 3 deletions
@@ -37,7 +37,7 @@ export function loadMaxTitles(): number | null {
const raw = getStorage()?.getItem(MAX_TITLES_KEY);
if (raw === null || raw === undefined) return null;
const value = Number(raw);
return Number.isInteger(value) && value > 0 ? value : null;
return (MAX_TITLES_OPTIONS as readonly number[]).includes(value) ? value : null;
} catch {
return null;
}