import { describe, expect, it } from 'vitest'; import { purifyDiplomacyHtml } from '../src/security/diplomacyHtml.js'; describe('diplomacy HTML purification', () => { it('removes executable markup, unsafe URLs, SVG, MathML, styles, and event handlers', () => { const dirty = [ '', '', '', '위험 링크', 'SVG', '', '

안전 본문

', ].join(''); const clean = purifyDiplomacyHtml(dirty); expect(clean).toBe('위험 링크SVG

안전 본문

'); expect(clean).not.toMatch(/script|onerror|onclick|javascript:|style=|class=| { const source = [ '

외교 제안

', '

굵게 기울임 밑줄 취소

', '

인용

', '', '
  1. 번호

', '링크', '문서', ].join(''); expect(purifyDiplomacyHtml(source)).toBe( [ '

외교 제안

', '

굵게 기울임 밑줄 취소

', '

인용

', '', '
  1. 번호

', '링크', '문서', ].join('') ); }); it('is idempotent and removes protocol-relative external resources', () => { const first = purifyDiplomacyHtml( '

본문

링크' ); expect(first).toBe('

본문

링크'); expect(purifyDiplomacyHtml(first)).toBe(first); }); });