#2560 Tetsing that the added css have balanced brackets

This commit is contained in:
Knut Sveidqvist
2021-12-14 23:54:31 +01:00
parent 38496c004b
commit 9c12502a36
4 changed files with 74 additions and 1 deletions

View File

@@ -974,6 +974,11 @@ export const directiveSanitizer = (args) => {
log.debug('sanitize deleting constr option', key);
delete args[key];
}
if (key.indexOf('themeCSS') >= 0) {
log.debug('sanitizing themeCss option');
args[key] = sanitizeCss(args[key]);
}
if (configKeys.indexOf(key) < 0) {
log.debug('sanitize deleting option', key);
delete args[key];
@@ -987,6 +992,16 @@ export const directiveSanitizer = (args) => {
}
}
};
export const sanitizeCss = (str) => {
const stringsearch = 'o';
const startCnt = (str.match(/\{/g) || []).length;
const endCnt = (str.match(/\}/g) || []).length;
if (startCnt !== endCnt) {
return '{ /* ERROR: Unbalanced CSS */ }';
}
// Todo add more checks here
return str;
};
export default {
assignWithDepth,
@@ -1013,4 +1028,5 @@ export default {
entityDecode,
initIdGeneratior,
directiveSanitizer,
sanitizeCss,
};