diff --git a/cypress/platform/xss19.html b/cypress/platform/xss19.html
new file mode 100644
index 0000000000..646162d0cf
--- /dev/null
+++ b/cypress/platform/xss19.html
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/directives.md b/docs/directives.md
index 5f7c720daa..b5ac493318 100644
--- a/docs/directives.md
+++ b/docs/directives.md
@@ -3,7 +3,7 @@
**Edit this Page** [![N|Solid](img/GitHub-Mark-32px.png)](https://github.com/mermaid-js/mermaid/blob/develop/docs/directives.md)
## Directives
-Directives gives a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration.
+Directives gives a diagram author the capability to alter the appearance of a diagram before rendering by changing the applied configuration.
Directives are divided into two sets or orders, by priority in parsing. The first set, containing 'init' or 'initialize' directives are loaded ahead of any other directive. While the other set, containing all other kinds of directives are parsed and factored into the rendering, only after 'init' and the desired graph-type are declared.
@@ -18,7 +18,7 @@ Directives are divided into two sets or orders, by priority in parsing. The firs
init would be an argument-directive: %%{init: { **insert argument here**}}%%
The json object that is passed as {**argument** } must be valid key value pairs and encased in quotation marks or it will be ignored.
-Valid Key Value pairs can be found in config.
+Valid Key Value pairs can be found in config.
The init/initialize directive is parsed earlier in the flow, this allows the incorporation of `%%init%%` directives into the mermaid diagram that is being rendered. Example:
```mmd
@@ -27,11 +27,11 @@ graph >
A-->B
```
-will set the `logLevel` to `debug` and the `theme` to `dark` for a flowchart diagram, changing the appearance of the diagram itself.
+will set the `logLevel` to `debug` and the `theme` to `dark` for a flowchart diagram, changing the appearance of the diagram itself.
Note: 'init' or 'initialize' are both acceptable as init directives. Also note that `%%init%%` and `%%initialize%%` directives will be grouped together after they are parsed. This means:
-```mmd
+```mmd2
%%{init: { 'logLevel': 'debug', 'theme': 'forest' } }%%
%%{initialize: { 'logLevel': 'fatal', "theme":'dark', 'startOnLoad': true } }%%
...
@@ -79,6 +79,6 @@ Init directives and any other non-multiline directives should be backwards compa
Multiline directives, however, will pose an issue and will render an error. This is unavoidable.
-# example
+# example
diff --git a/src/dagre-wrapper/createLabel.js b/src/dagre-wrapper/createLabel.js
index bf360773c8..ed7b9f6fb1 100644
--- a/src/dagre-wrapper/createLabel.js
+++ b/src/dagre-wrapper/createLabel.js
@@ -1,7 +1,9 @@
import { select } from 'd3';
import { log } from '../logger'; // eslint-disable-line
import { getConfig } from '../config';
-import { evaluate } from '../diagrams/common/common';
+import { sanitizeText, evaluate } from '../diagrams/common/common';
+
+const sanitizeTxt = (txt) => sanitizeText(txt, getConfig());
/**
* @param dom
diff --git a/src/diagrams/class/classDb.js b/src/diagrams/class/classDb.js
index ba33b5f777..163ac10ddb 100644
--- a/src/diagrams/class/classDb.js
+++ b/src/diagrams/class/classDb.js
@@ -13,6 +13,8 @@ let classCounter = 0;
let funs = [];
+const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
+
export const parseDirective = function (statement, context, type) {
mermaidAPI.parseDirective(this, statement, context, type);
};
@@ -141,11 +143,11 @@ export const addMember = function (className, member) {
if (memberString.startsWith('<<') && memberString.endsWith('>>')) {
// Remove leading and trailing brackets
- theClass.annotations.push(memberString.substring(2, memberString.length - 2));
+ theClass.annotations.push(sanitizeText(memberString.substring(2, memberString.length - 2)));
} else if (memberString.indexOf(')') > 0) {
- theClass.methods.push(memberString);
+ theClass.methods.push(sanitizeText(memberString));
} else if (memberString) {
- theClass.members.push(memberString);
+ theClass.members.push(sanitizeText(memberString));
}
}
};
@@ -161,7 +163,7 @@ export const cleanupLabel = function (label) {
if (label.substring(0, 1) === ':') {
return common.sanitizeText(label.substr(1).trim(), configApi.getConfig());
} else {
- return label.trim();
+ return sanitizeText(label.trim());
}
};
diff --git a/src/diagrams/class/classRenderer-v2.js b/src/diagrams/class/classRenderer-v2.js
index a128d8e2e5..0f552d2ec4 100644
--- a/src/diagrams/class/classRenderer-v2.js
+++ b/src/diagrams/class/classRenderer-v2.js
@@ -17,6 +17,8 @@ parser.yy = classDb;
let idCache = {};
const padding = 20;
+const sanitizeText = (txt) => common.sanitizeText(txt, getConfig());
+
const conf = {
dividerMargin: 10,
padding: 5,
@@ -103,7 +105,7 @@ export const addClasses = function (classes, g) {
g.setNode(vertex.id, {
labelStyle: styles.labelStyle,
shape: _shape,
- labelText: vertexText,
+ labelText: sanitizeText(vertexText),
classData: vertex,
rx: radious,
ry: radious,