Commit 9a4f69d
committed
fix(desktop): reject NaN/Infinity usage values to prevent counter corruption
A bad provider/IPC payload (NaN, Infinity, or negative) would silently
poison weekUsage totals across sessions, since the previous guard only
checked typeof === 'number'. Tighten validation with Number.isFinite +
non-negative at both the parse-side (IPC payload → state) and the
storage-load side (rehydrate from localStorage).
On rejection: drop the bad value, console.warn, and surface a toast via
the existing weekly-usage error UI surface (errors.weekUsageInvalid).
Addresses PR #47 codex Major.1 parent 52af5f2 commit 9a4f69d
4 files changed
Lines changed: 87 additions & 14 deletions
File tree
- apps/desktop/src/renderer/src
- packages/i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
405 | 440 | | |
406 | 441 | | |
407 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
216 | 242 | | |
217 | 243 | | |
218 | 244 | | |
| |||
228 | 254 | | |
229 | 255 | | |
230 | 256 | | |
231 | | - | |
232 | | - | |
233 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
234 | 260 | | |
235 | 261 | | |
236 | 262 | | |
| |||
375 | 401 | | |
376 | 402 | | |
377 | 403 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 404 | + | |
383 | 405 | | |
384 | 406 | | |
385 | 407 | | |
| |||
400 | 422 | | |
401 | 423 | | |
402 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
403 | 434 | | |
404 | 435 | | |
405 | 436 | | |
| |||
758 | 789 | | |
759 | 790 | | |
760 | 791 | | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
| 792 | + | |
766 | 793 | | |
767 | 794 | | |
768 | 795 | | |
| |||
779 | 806 | | |
780 | 807 | | |
781 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
782 | 818 | | |
783 | 819 | | |
784 | 820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| 398 | + | |
398 | 399 | | |
399 | 400 | | |
400 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| 397 | + | |
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
| |||
0 commit comments