Verschaerfe Pruefung auf ganze positive Eintragsnummern
- Fuegt isPositiveInteger() hinzu fuer Validierung von Eintragsnummern - nextEntryId und entry.entryId muessen ganze Zahlen >= 1 sein - Akzeptiert nicht mehr negative, gebrochene oder Null-Werte - Vier neue Tests pruefen die verstaerkten Anforderungen - Alle bestehenden Tests bleiben gruen Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -24,6 +24,10 @@ function isFiniteNumber(value) {
|
||||
return typeof value === 'number' && Number.isFinite(value);
|
||||
}
|
||||
|
||||
function isPositiveInteger(value) {
|
||||
return typeof value === 'number' && Number.isInteger(value) && value >= 1;
|
||||
}
|
||||
|
||||
function isUsableStack(stack) {
|
||||
return (
|
||||
isPlainObject(stack)
|
||||
@@ -36,7 +40,7 @@ function isUsableStack(stack) {
|
||||
function isUsableEntry(entry) {
|
||||
return (
|
||||
isPlainObject(entry)
|
||||
&& isFiniteNumber(entry.entryId)
|
||||
&& isPositiveInteger(entry.entryId)
|
||||
&& typeof entry.stackId === 'string'
|
||||
&& isPlainObject(entry.spec)
|
||||
);
|
||||
@@ -65,7 +69,7 @@ export function loadSession(store) {
|
||||
if (!raw) return null;
|
||||
const parsed = JSON.parse(raw);
|
||||
if (!Array.isArray(parsed.stacks) || !Array.isArray(parsed.entries)) return null;
|
||||
if (!isFiniteNumber(parsed.nextEntryId)) return null;
|
||||
if (!isPositiveInteger(parsed.nextEntryId)) return null;
|
||||
if (!parsed.stacks.every(isUsableStack)) return null;
|
||||
if (!parsed.entries.every(isUsableEntry)) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user