mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 22:39:26 +02:00
Add sanitize to properties and link in Sequence Diagram
This commit is contained in:
@@ -563,7 +563,8 @@ context('Sequence diagram', () => {
|
||||
});
|
||||
});
|
||||
context('links', () => {
|
||||
it('should support actor links and properties', () => {
|
||||
it('should support actor links and properties EXPERIMENTAL: USE WITH CAUTION', () => {
|
||||
//Be aware that the syntax for "properties" is likely to be changed.
|
||||
imgSnapshotTest(
|
||||
`
|
||||
%%{init: { "config": { "mirrorActors": true, "forceMenus": true }}}%%
|
||||
@@ -583,7 +584,8 @@ context('Sequence diagram', () => {
|
||||
{ logLevel: 0, sequence: { mirrorActors: true, noteFontSize: 18, noteFontFamily: 'Arial' } }
|
||||
);
|
||||
});
|
||||
it('should support actor links and properties when not mirrored', () => {
|
||||
it('should support actor links and properties when not mirrored EXPERIMENTAL: USE WITH CAUTION', () => {
|
||||
//Be aware that the syntax for "properties" is likely to be changed.
|
||||
imgSnapshotTest(
|
||||
`
|
||||
%%{init: { "config": { "mirrorActors": false, "forceMenus": true, "wrap": true }}}%%
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import mermaidAPI from '../../mermaidAPI';
|
||||
import * as configApi from '../../config';
|
||||
import { log } from '../../logger';
|
||||
import { sanitizeText } from '../common/common';
|
||||
|
||||
let prevActor = undefined;
|
||||
let actors = {};
|
||||
@@ -219,7 +220,8 @@ export const addLinks = function (actorId, text) {
|
||||
const actor = getActor(actorId);
|
||||
// JSON.parse the text
|
||||
try {
|
||||
const links = JSON.parse(text.text);
|
||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||
const links = JSON.parse(sanitizedText);
|
||||
// add the deserialized text to the actor's links field.
|
||||
insertLinks(actor, links);
|
||||
} catch (e) {
|
||||
@@ -232,9 +234,10 @@ export const addALink = function (actorId, text) {
|
||||
const actor = getActor(actorId);
|
||||
try {
|
||||
const links = {};
|
||||
var sep = text.text.indexOf('@');
|
||||
var label = text.text.slice(0, sep - 1).trim();
|
||||
var link = text.text.slice(sep + 1).trim();
|
||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||
var sep = sanitizedText.indexOf('@');
|
||||
var label = sanitizedText.slice(0, sep - 1).trim();
|
||||
var link = sanitizedText.slice(sep + 1).trim();
|
||||
|
||||
links[label] = link;
|
||||
// add the deserialized text to the actor's links field.
|
||||
@@ -259,7 +262,8 @@ export const addProperties = function (actorId, text) {
|
||||
const actor = getActor(actorId);
|
||||
// JSON.parse the text
|
||||
try {
|
||||
const properties = JSON.parse(text.text);
|
||||
let sanitizedText = sanitizeText(text.text, configApi.getConfig());
|
||||
const properties = JSON.parse(sanitizedText);
|
||||
// add the deserialized text to the actor's property field.
|
||||
insertProperties(actor, properties);
|
||||
} catch (e) {
|
||||
|
@@ -976,7 +976,8 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com
|
||||
expect(actors.a.links["Tests"]).toBe("https://tests.contoso.com/?svc=alice@contoso.com");
|
||||
});
|
||||
|
||||
it('it should handle properties', function () {
|
||||
it('it should handle properties EXPERIMENTAL: USE WITH CAUTION', function () {
|
||||
//Be aware that the syntax for "properties" is likely to be changed.
|
||||
const str = `
|
||||
sequenceDiagram
|
||||
participant a as Alice
|
||||
|
Reference in New Issue
Block a user