mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-24 17:34:17 +03:00
Santizes custom CSS
This commit is contained in:
parent
d040d212fc
commit
1965513096
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div :class="`collapsable ${checkSpanNum(cols, 'col')} ${checkSpanNum(rows, 'row')}`"
|
||||
:style="`${color ? 'background: '+color : ''}; ${customStyles}`"
|
||||
:style="`${color ? 'background: '+color : ''}; ${sanitizeCustomStyles(customStyles)};`"
|
||||
>
|
||||
<input
|
||||
:id="`collapsible-${uniqueKey}`"
|
||||
@ -46,6 +46,11 @@ export default {
|
||||
numSpan = (numSpan > maxSpan) ? maxSpan : numSpan;
|
||||
return `${classPrefix}-${numSpan}`;
|
||||
},
|
||||
/* Removes all special characters, except those allowed in valid CSS */
|
||||
sanitizeCustomStyles(userCss) {
|
||||
return userCss ? userCss.replace(/[^a-zA-Z0-9- :;.]/g, '') : '';
|
||||
},
|
||||
/* If not already done, then add object structure to local storage */
|
||||
initialiseStorage() {
|
||||
const initStorage = () => localStorage.setItem('collapseState', JSON.stringify({}));
|
||||
if (!localStorage.collapseState) initStorage(); // If not yet set, then init localstorage
|
||||
|
Loading…
Reference in New Issue
Block a user