From 39d7ebd32e1fd82663fb80de37caf57dce329238 Mon Sep 17 00:00:00 2001 From: darshanr0107 Date: Mon, 13 Oct 2025 13:16:58 +0530 Subject: [PATCH 1/5] fix: escaped p tags in sandbox mode on-behalf-of: @Mermaid-Chart --- .../src/diagrams/common/common.spec.ts | 25 +++++++++++++++++++ .../mermaid/src/diagrams/common/common.ts | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) 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('