dc603b8b49
Enhances validation to clean corrupted items at load time while preserving valid ones, rather than discarding entire sections. Also auto-capitalizes first letter of items for consistency. New capability - Granular Item Cleaning: 1. **cleanItemString()** (src/utils/security.js): - Parses item string, removes bad items, re-serializes clean ones - Applies ALL parsing rules: markdown, sanitization, length limits - Used at load time to clean persisted data immediately - Returns "None" if no valid items remain 2. **Enhanced validateStoredInventory()**: - Now cleans items within each location - Only removes locations if ALL items are invalid - Example: "Home": "Sword, __proto__, Shield" → "Home": "Sword, Shield" - Example: "Bad": "__proto__, constructor" → location removed 3. **Enhanced validateInventoryStructure()** (src/core/persistence.js): - Cleans onPerson, stored, and assets at load time - Logs exactly what was cleaned for debugging - Auto-saves cleaned data back to storage Auto-Capitalization: - Added to cleanSingleItem() in itemParser.js - Capitalizes first letter of each item after all cleaning - Preserves rest of case: "iPhone" → "iPhone" (not "Iphone") - Examples: "sword" → "Sword", "3x potions" → "3x potions" Behavior examples: Before (threw away entire array): - "Home": "Sword, " + "A".repeat(600) + ", Shield" → Entire location lost After (granular cleaning): - "Home": "Sword, " + "A".repeat(600) + ", Shield" → "Home": "Sword, AAA...(500 chars), Shield" Before (kept corrupted data): - onPerson: "sword, __proto__, shield" → Stored as-is, filtered only at render After (cleaned at load): - onPerson: "Sword, Shield" → Cleaned and saved immediately, capitalized Benefits: - ✓ Preserves valid items when some are corrupted - ✓ Cleans data at source, not just at render - ✓ Detailed logging of what was cleaned - ✓ Consistent capitalization across all items - ✓ Single source of truth for "valid item"