mirror of
				https://github.com/mermaid-js/mermaid.git
				synced 2025-11-04 12:54:08 +01:00 
			
		
		
		
	fix multicharacter sanitization
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
				
			|||||||
import { arc as d3arc, select } from 'd3';
 | 
					import { arc as d3arc, select } from 'd3';
 | 
				
			||||||
import { createText } from '../../rendering-util/createText.js';
 | 
					import { createText } from '../../rendering-util/createText.js';
 | 
				
			||||||
 | 
					import DOMPurify from 'dompurify';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const MAX_SECTIONS = 12;
 | 
					const MAX_SECTIONS = 12;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12,9 +13,10 @@ const MAX_SECTIONS = 12;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
const processHtmlContent = async function (textElem, node, conf, isVirtual = false) {
 | 
					const processHtmlContent = async function (textElem, node, conf, isVirtual = false) {
 | 
				
			||||||
  // Create temporary text to get initial dimensions
 | 
					  // Create temporary text to get initial dimensions
 | 
				
			||||||
 | 
					  const sanitizedHtml = DOMPurify.sanitize(node.descr, { ALLOWED_TAGS: [] });
 | 
				
			||||||
  const tempText = textElem
 | 
					  const tempText = textElem
 | 
				
			||||||
    .append('text')
 | 
					    .append('text')
 | 
				
			||||||
    .text(node.descr.replace(/<[^>]*>/g, ''))
 | 
					    .text(sanitizedHtml)
 | 
				
			||||||
    .attr('dy', '1em')
 | 
					    .attr('dy', '1em')
 | 
				
			||||||
    .attr('alignment-baseline', 'middle')
 | 
					    .attr('alignment-baseline', 'middle')
 | 
				
			||||||
    .attr('dominant-baseline', 'middle')
 | 
					    .attr('dominant-baseline', 'middle')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user