diff --git a/packages/mermaid/src/diagrams/common/common.spec.ts b/packages/mermaid/src/diagrams/common/common.spec.ts index 3c7e0fdb8..edaf0b6dd 100644 --- a/packages/mermaid/src/diagrams/common/common.spec.ts +++ b/packages/mermaid/src/diagrams/common/common.spec.ts @@ -70,6 +70,31 @@ describe('Sanitize text', () => { }); expect(result).not.toContain('javascript:alert(1)'); }); + + it('should allow HTML tags in sandbox mode', () => { + const htmlStr = '
This is a bold text
'; + const result = sanitizeText(htmlStr, { + securityLevel: 'sandbox', + flowchart: { htmlLabels: true }, + }); + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain(''); + expect(result).toContain('
'); + }); + + it('should remove script tags in sandbox mode', () => { + const maliciousStr = 'Hello world
'; + const result = sanitizeText(maliciousStr, { + securityLevel: 'sandbox', + flowchart: { htmlLabels: true }, + }); + expect(result).not.toContain('