Fix code review findings for Story 3.3: Preset Import & Export
Security & Quality Improvements:
- Fix XSS vulnerabilities in PresetImportDialog, PresetExportDialog, and templates
- Add resource leak protection in downloadExportFile() with try/finally
- Fix encapsulation violation by using public API instead of _presetsCache
- Add rollback mechanism for partial failures in replace mode
- Add preset name validation (length, characters, empty check)
- Add duplicate name detection within import files
- Add file size validation (5MB limit) and type validation
- Fix event listener leaks with proper cleanup in _onRender/_onClose
- Add constructor parameter validation for all dialogs
Acceptance Criteria Compliance:
- Fix AC-2: Export filename now uses world name (via parent.name)
- Fix AC-6: Error message matches spec exactly ('Import failed: invalid JSON format')
- Fix AC-8: Merge/Replace messages match spec format
Code Quality:
- Add shared HTML escaping utilities (src/utils/html.js)
- Consolidate duplicate localization strings (removed 28 duplicates from SCRYING_POOL)
- Use SCENE_PRESET_VERSION constant instead of hardcoded 1
- Handle null options in importPresets()
- Graceful handling of skipValidation with invalid data
Test Results: 679 passed, 3 failed (pre-existing in DirectorsBoard)
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -135,34 +135,6 @@
|
||||
}
|
||||
},
|
||||
"SCRYING_POOL": {
|
||||
"ExportPresetsTitle": "Export Scene Presets",
|
||||
"ExportPresetsDescription": "Download all scene presets as a JSON file that can be imported into another world.",
|
||||
"Scene": "Scene",
|
||||
"PresetCount": "Presets",
|
||||
"Filename": "Filename",
|
||||
"Export": "Export",
|
||||
"Cancel": "Cancel",
|
||||
"Exporting": "Exporting…",
|
||||
"ExportSuccess": "Scene presets exported successfully.",
|
||||
"ExportFailed": "Failed to export presets",
|
||||
"ImportPresetsTitle": "Import Scene Presets",
|
||||
"ImportPresetsDescription": "Upload a JSON file containing scene presets to add to this scene.",
|
||||
"SelectFile": "Select File",
|
||||
"ChooseFile": "Choose a JSON file…",
|
||||
"ImportMode": "Import Mode",
|
||||
"ImportModeMerge": "Merge",
|
||||
"ImportModeReplace": "Replace",
|
||||
"ImportModeMergeHint": "Add new presets, skip duplicates",
|
||||
"ImportModeReplaceHint": "Delete all existing presets and import new ones",
|
||||
"PreviewTitle": "Preview",
|
||||
"PresetExistsWillBeSkipped": "Already exists - will be skipped",
|
||||
"Import": "Import",
|
||||
"ConfirmReplace": "Replace All",
|
||||
"Importing": "Importing…",
|
||||
"ImportFailed": "Failed to import presets",
|
||||
"SelectFileFirst": "Please select a file first",
|
||||
"ExistingPresetsWarning": "This scene has {existingPresetCount} existing preset(s).",
|
||||
"ReplaceConfirmation": "This will delete all {existingPresetCount} existing preset(s) and replace them with the imported ones. This cannot be undone.",
|
||||
"UnknownScene": "Unknown Scene",
|
||||
"firstBadgeEncounter": "First Badge Encounter"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user