Sanitize Cytoscape tooltip labels to prevent XSS

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
2026-03-08 10:41:48 +08:00
parent 1d621bf304
commit e275e79a63
4 changed files with 40 additions and 4 deletions

View File

@@ -0,0 +1,19 @@
// The Lucia project.
// Copyright 2026-2026 DSP, inc. All rights reserved.
// Authors:
// codex@openai.com (Codex), 2026/03/08
import { describe, it, expect } from 'vitest';
import { createTooltipContent } from '@/module/tooltipContent.js';
describe('createTooltipContent', () => {
it('renders untrusted label as plain text', () => {
const label = '<img src=x onerror=alert(1)>Node';
const content = createTooltipContent(label);
expect(content.textContent).toBe(label);
expect(content.innerHTML).toContain('&lt;img');
expect(content.querySelector('img')).toBeNull();
});
});