Language: JavaScript
Label: vulnerable
CWE: CWE-79 \u2014 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.

Code:
for(var e=[],g=2;g<c.length;g++){var q=mxUtils.trim(c[g]);"["!=q&&"]"!=q&&"%%"!=q.substring(0,2)&&"##"!=q.substring(0,2)&&(q=c[g].replace(/[-|>]/g," "),""!=mxUtils.trim(q)&&" "==q.charAt(0)&&e.push(q))}return"mindmap\nroot(("+mxUtils.trim(c[1])+"))\n"+e.join("\n")};EditorUi.prototype.extractMermaidDeclaration=function(c){"o\n\n"==c.substring(0,3)&&(c=c.substring(3));var e=c.split("```");e=1<e.length?e:c.split("<pre>");e=1<e.length?e:c.split("~~~");e=1<e.length?e:c.split("%%");e=1<e.length?e:c.split("(Begins)");
e=mxUtils.trim(1>=e.length?c:e[1]);var g=e.split("\n");if(0<g.length&&"mermaid"==mxUtils.trim(g[0])||1<g.length&&0<=mxUtils.indexOf(EditorUi.mermaidDiagramTypes,g[1]))g.shift(),e=mxUtils.trim(g.join("\n")),g=e.split("\n");var q=g[0].split(" ")[0].replace(/:$/,"");try{"mindmap"==q&&2<g.length&&(e=this.extractMermaidMindmap(g))}catch(p){}"@"!=q.charAt(0)&&0>mxUtils.indexOf(EditorUi.mermaidDiagramTypes,q)&&(e="classDiagram\n"+e);EditorUi.debug("EditorUi.extractMermaidDeclaration","\nlines:",g,"\ntype:",
q,"\nvalue:",c,"\ntext:",e);return e};EditorUi.prototype.generateMermaidImage=function(c,e,g,q,p){var t=mxUtils.bind(this,function(B){this.loadingMermaid=!1;null!=q?q(B):this.handleError(B)}),x=mxUtils.bind(this,function(){try{this.loadingMermaid=!1;e=null!=e?e:mxUtils.clone(EditorUi.defaultMermaidConfig);e.securityLevel="strict";e.startOnLoad=!1;Editor.isDarkMode()&&(e.theme="dark");var B=mxUtils.bind(this,function(I){try{if(mxClient.IS_IE||mxClient.IS_IE11)I=I.replace(/ xmlns:\S*="http:\/\/www.w3.org\/XML\/1998\/namespace"/g,