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:
2026-05-23 18:57:32 +02:00
parent a1e8886fce
commit ea2c2ea093
7 changed files with 354 additions and 131 deletions
+6 -6
View File
@@ -1,29 +1,29 @@
<div class="sp-dialog-content">
<p class="sp-export-description">
{{localize "SCRYING_POOL.ExportPresetsDescription"}}
{{localize "video-view-manager.presetExport.description"}}
</p>
<div class="sp-export-info">
<span class="sp-info-label">{{localize "SCRYING_POOL.Scene"}}:</span>
<span class="sp-info-label">{{localize "video-view-manager.presetExport.scene"}}:</span>
<span class="sp-info-value">{{sceneName}}</span>
</div>
<div class="sp-export-info">
<span class="sp-info-label">{{localize "SCRYING_POOL.PresetCount"}}:</span>
<span class="sp-info-label">{{localize "video-view-manager.presetExport.presetCount"}}:</span>
<span class="sp-info-value">{{presetCount}}</span>
</div>
<div class="sp-export-info">
<span class="sp-info-label">{{localize "SCRYING_POOL.Filename"}}:</span>
<span class="sp-info-label">{{localize "video-view-manager.presetExport.filename"}}:</span>
<span class="sp-info-value sp-filename">{{filename}}</span>
</div>
</div>
<div class="sp-dialog-buttons">
<button type="button" class="sp-btn sp-btn-primary sp-export-btn">
<i class="fas fa-download"></i> {{localize "SCRYING_POOL.Export"}}
<i class="fas fa-download"></i> {{localize "video-view-manager.presetExport.export"}}
</button>
<button type="button" class="sp-btn sp-btn-secondary" data-action="close">
{{localize "SCRYING_POOL.Cancel"}}
{{localize "video-view-manager.presetExport.cancel"}}
</button>
</div>