@capillarytech/cap-ui-utils 1.4.25-alpha.1 → 1.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/cap-ui-utils",
|
|
3
|
-
"version": "1.4.25
|
|
3
|
+
"version": "1.4.25",
|
|
4
4
|
"description": "Utility functions shared accross all the modules",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
},
|
|
9
9
|
"author": "Rajshekar",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"handlebars": "4.0.11",
|
|
12
|
+
"lodash": "4.17.11",
|
|
13
|
+
"moment-timezone": "^0.5.25",
|
|
11
14
|
"react": "^16.13.0",
|
|
12
15
|
"react-ga": "^2.7.0",
|
|
13
|
-
"tti-polyfill": "^0.2.2",
|
|
14
|
-
"moment-timezone": "^0.5.25",
|
|
15
16
|
"react-intl": "2.7.2",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
17
|
+
"tti-polyfill": "^0.2.2",
|
|
18
|
+
"windowed-observable": "^1.0.0"
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export const sanitizeTemplateWithRegexp = (content) => {
|
|
2
|
-
const forbiddenTags = process.env.TMPL_SANITIZE_FORBIDDEN_TAGS ? JSON.parse(process.env.TMPL_SANITIZE_FORBIDDEN_TAGS) : ['script'];
|
|
3
|
-
const forbiddenAttrs = process.env.TMPL_SANITIZE_FORBIDDEN_ATTRS ? JSON.parse(process.env.TMPL_SANITIZE_FORBIDDEN_ATTRS) : ['onclick', 'onmouseover', 'onmouseout'];
|
|
4
|
-
const forbiddenHrefJavaScript = ["javascript:"];
|
|
5
|
-
const tagsJoined = forbiddenTags.join('|');
|
|
6
|
-
const attrsJoined = forbiddenAttrs.join('|');
|
|
7
|
-
const hrefsJoined = forbiddenHrefJavaScript.join('|');
|
|
8
|
-
const fullTagRegex = new RegExp(`<${tagsJoined}\\b[^<]*(?:(?!<\/${tagsJoined}>)<[^<]*)*<\/${tagsJoined}>`, 'gi');
|
|
9
|
-
const emptyTagRegex = new RegExp(`<${tagsJoined}.*\/?>`, 'gi');
|
|
10
|
-
const attrRegex = new RegExp(`\\b(${attrsJoined})\\s*=\\s*(\"[^\"]*\"|'[^']*'|[^>|&|\/\\s]+)`, 'gi');
|
|
11
|
-
const hrefJavaScriptRegex = new RegExp(`href\\s*=\\s*(["\'])(?:\\*?.)*?(?:\\?\\")?${hrefsJoined}(?:\\\\?.)*?\\1`, 'gi');
|
|
12
|
-
const hrefRegexForJsonString = new RegExp(`href=\\\\["\']${hrefsJoined}.*?\\\\["\']`, 'gi'); // This is to find the href in json format for BEE editor
|
|
13
|
-
const encodedScriptTagRegex = new RegExp(`(?:<|<)${tagsJoined}(?:\s[^>]*|)[^*]*>`, 'gi');
|
|
14
|
-
|
|
15
|
-
return content
|
|
16
|
-
.replaceAll(fullTagRegex, '')
|
|
17
|
-
.replaceAll(encodedScriptTagRegex, '')
|
|
18
|
-
.replaceAll(emptyTagRegex, '')
|
|
19
|
-
.replaceAll(attrRegex, '')
|
|
20
|
-
.replaceAll(hrefJavaScriptRegex, 'href="#"')
|
|
21
|
-
.replaceAll(hrefRegexForJsonString, 'href=\\\"#\\\"'); // This will ensure to remain the content in json format for BEE editor
|
|
22
|
-
};
|