import assert from 'node:assert/strict' import test from 'node:test' import { sanitizeHtmlBlock } from '../lib/markdown-html-block.js' /** * 실행성 HTML 우회 입력을 제거하는지 검증한다. * @returns {void} */ const testDangerousHtmlRemoval = () => { const attacks = [ '', '링크', '위험', '', '
본문
', '' ] for (const attack of attacks) { const sanitized = sanitizeHtmlBlock(attack) assert.doesNotMatch(sanitized, /onerror|onclick|javascript:| { const sanitized = sanitizeHtmlBlock( '
제목본문
' + '외부 링크' ) assert.match(sanitized, //) assert.match(sanitized, /scope="col"/) assert.match(sanitized, /rel="noopener noreferrer"/) } test('HTML 블록의 실행성 태그·속성·URL을 제거한다', testDangerousHtmlRemoval) test('HTML 블록의 안전한 표와 링크를 보존한다', testSafeHtmlPreservation)