feat: add sanitization consistently

This commit is contained in:
Cory Gwin
2022-04-07 18:36:30 +00:00
committed by GitHub
parent 7761561ac2
commit d36f45ec58
3 changed files with 18 additions and 4 deletions

View File

@@ -1,12 +1,15 @@
import { log } from '../../logger'; import { log } from '../../logger';
import mermaidAPI from '../../mermaidAPI'; import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config'; import * as configApi from '../../config';
import common from '../common/common';
let entities = {}; let entities = {};
let relationships = []; let relationships = [];
let title = ''; let title = '';
let description = ''; let description = '';
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
const Cardinality = { const Cardinality = {
ZERO_OR_ONE: 'ZERO_OR_ONE', ZERO_OR_ONE: 'ZERO_OR_ONE',
ZERO_OR_MORE: 'ZERO_OR_MORE', ZERO_OR_MORE: 'ZERO_OR_MORE',
@@ -69,7 +72,8 @@ const getRelationships = () => relationships;
// Keep this - TODO: revisit...allow the diagram to have a title // Keep this - TODO: revisit...allow the diagram to have a title
const setTitle = function (txt) { const setTitle = function (txt) {
title = txt; let sanitizedText = sanitizeText(txt, configApi.getConfig());
title = sanitizedText;
}; };
const getTitle = function () { const getTitle = function () {
@@ -77,7 +81,8 @@ const getTitle = function () {
}; };
const setAccDescription = function (txt) { const setAccDescription = function (txt) {
description = txt; let sanitizedText = sanitizeText(txt, configApi.getConfig());
description = sanitizedText;
}; };
const getAccDescription = function () { const getAccDescription = function () {

View File

@@ -4,6 +4,10 @@ import { log } from '../../logger';
import * as configApi from '../../config'; import * as configApi from '../../config';
import utils from '../../utils'; import utils from '../../utils';
import mermaidAPI from '../../mermaidAPI'; import mermaidAPI from '../../mermaidAPI';
import common from '../common/common';
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
let dateFormat = ''; let dateFormat = '';
let axisFormat = ''; let axisFormat = '';
@@ -108,7 +112,8 @@ export const getLinks = function () {
}; };
export const setTitle = function (txt) { export const setTitle = function (txt) {
title = txt; let sanitizedText = sanitizeText(txt, configApi.getConfig());
title = sanitizedText;
}; };
export const getTitle = function () { export const getTitle = function () {

View File

@@ -1,5 +1,7 @@
import mermaidAPI from '../../mermaidAPI'; import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config'; import * as configApi from '../../config';
import common from '../common/common';
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
let title = ''; let title = '';
let currentSection = ''; let currentSection = '';
@@ -21,7 +23,9 @@ export const clear = function () {
}; };
export const setTitle = function (txt) { export const setTitle = function (txt) {
title = txt; let sanitizedText = sanitizeText(txt, configApi.getConfig());
title = sanitizedText;
}; };
export const getTitle = function () { export const getTitle = function () {