Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-block-sanitize-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mermaid': patch
---

fix(block-beta): respect current DOMPurify config when sanitizing labels
13 changes: 13 additions & 0 deletions packages/mermaid/src/diagrams/block/parser/block.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// @ts-ignore: jison doesn't export types
import block from './block.jison';
import db from '../blockDB.js';
import * as configApi from '../../../config.js';
import { log } from '../../../logger.js';

describe('Block diagram', function () {
describe('when parsing a block diagram graph it should handle > ', function () {
beforeEach(function () {
configApi.setSiteConfig({});
configApi.reset();
block.parser.yy = db;
block.parser.yy.clear();
block.parser.yy.getLogger = () => console;
Expand Down Expand Up @@ -34,6 +37,16 @@ describe('Block diagram', function () {
expect(blocks[0].label).toBe('A label');
expect(blocks[0].type).toBe('square');
});
it('sanitizes labels with the current dompurify config', () => {
configApi.setSiteConfig({ dompurifyConfig: { FORBID_TAGS: ['b'] } });
const str = `block
id["<b>Bold</b>"]
`;

block.parse(str);
const blocks = db.getBlocks();
expect(blocks[0].label).toBe('Bold');
});
it('a diagram with multiple nodes', () => {
const str = `block
id1
Expand Down
Loading