mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 05:49:43 +02:00
Checking for shenanigans in the themeCSF field
This commit is contained in:
@@ -37,6 +37,17 @@ export const removeScript = (txt) => {
|
|||||||
return rs;
|
return rs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple css sanitization
|
||||||
|
*/
|
||||||
|
export const sanitizeCSS = (css) => {
|
||||||
|
if (css.indexOf('url') >= 0) return '';
|
||||||
|
if (css.indexOf('/*') >= 0) return '';
|
||||||
|
if (css.indexOf('//') >= 0) return '';
|
||||||
|
|
||||||
|
return css;
|
||||||
|
};
|
||||||
|
|
||||||
const sanitizeMore = (text, config) => {
|
const sanitizeMore = (text, config) => {
|
||||||
let txt = text;
|
let txt = text;
|
||||||
let htmlLabels = true;
|
let htmlLabels = true;
|
||||||
@@ -112,4 +123,5 @@ export default {
|
|||||||
removeScript,
|
removeScript,
|
||||||
getUrl,
|
getUrl,
|
||||||
evaluate,
|
evaluate,
|
||||||
|
sanitizeCSS,
|
||||||
};
|
};
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
import { select } from 'd3';
|
import { select } from 'd3';
|
||||||
import { compile, serialize, stringify } from 'stylis';
|
import { compile, serialize, stringify } from 'stylis';
|
||||||
|
import common from './diagrams/common/common';
|
||||||
import pkg from '../package.json';
|
import pkg from '../package.json';
|
||||||
import * as configApi from './config';
|
import * as configApi from './config';
|
||||||
import classDb from './diagrams/class/classDb';
|
import classDb from './diagrams/class/classDb';
|
||||||
@@ -284,7 +285,7 @@ const render = function (id, _txt, cb, container) {
|
|||||||
let userStyles = '';
|
let userStyles = '';
|
||||||
// user provided theme CSS
|
// user provided theme CSS
|
||||||
if (cnf.themeCSS !== undefined) {
|
if (cnf.themeCSS !== undefined) {
|
||||||
userStyles += `\n${cnf.themeCSS}`;
|
userStyles += `\n${common.sanitizeCSS(cnf.themeCSS)}`;
|
||||||
}
|
}
|
||||||
// user provided theme CSS
|
// user provided theme CSS
|
||||||
if (cnf.fontFamily !== undefined) {
|
if (cnf.fontFamily !== undefined) {
|
||||||
|
Reference in New Issue
Block a user