CRITICAL SECURITY FIX - Prevents XSS attacks through malicious Mermaid diagrams
Changes:
1. MermaidViewer.tsx:
- Changed securityLevel from loose to strict
- Disabled htmlLabels to prevent HTML injection
- Added DOMPurify sanitization for rendered SVG
- Added manual URI checking for javascript: and data: protocols
2. useGraphData.ts:
- Added sanitizeMermaidLabel() function
- Sanitizes user input before inserting into Mermaid diagrams
- Removes HTML tags, JavaScript protocols, control characters
- Escapes Mermaid special characters
- Truncates to 200 chars for DoS prevention
Security improvements:
- Defense in depth: 4 layers of protection
- Blocks: script injection, event handlers, JavaScript URIs, data URIs
- Test coverage: 90.15% (exceeds 85% requirement)
- All attack vectors tested and blocked
Fixes#190
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>