@shopgate/pwa-common 7.34.0-beta.1 → 7.34.0-beta.3
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.
|
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { embeddedMedia, configuration } from '@shopgate/engage/core/collections';
|
|
6
6
|
import { CONFIGURATION_COLLECTION_KEY_UNIVERSAL_LINK_HANDLER } from '@shopgate/engage/core/constants';
|
|
7
|
+
import SafeHtml from '@shopgate/engage/components/SafeHtml';
|
|
7
8
|
import EmbeddedMedia from "../EmbeddedMedia";
|
|
8
9
|
import parseHTML from "../../helpers/html/parseHTML";
|
|
9
10
|
import connect from "./connector";
|
|
@@ -132,17 +133,15 @@ let HtmlSanitizer = /*#__PURE__*/function (_Component) {
|
|
|
132
133
|
comfortCookiesAccepted: this.props.comfortCookiesAccepted,
|
|
133
134
|
statisticsCookiesAccepted: this.props.statisticsCookiesAccepted
|
|
134
135
|
};
|
|
135
|
-
const
|
|
136
|
-
__html: parseHTML(this.props.children, this.props.decode, this.props.settings, this.props.processStyles, cookieConsentSettings)
|
|
137
|
-
};
|
|
136
|
+
const html = parseHTML(this.props.children, this.props.decode, this.props.settings, this.props.processStyles, cookieConsentSettings, this.props.allowScripts);
|
|
138
137
|
const {
|
|
139
138
|
wrapper: Wrapper
|
|
140
139
|
} = this.props;
|
|
141
140
|
return /*#__PURE__*/_jsx(Wrapper, {
|
|
142
141
|
cookieConsentSettings: cookieConsentSettings,
|
|
143
|
-
children: /*#__PURE__*/_jsx(
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
children: /*#__PURE__*/_jsx(SafeHtml, {
|
|
143
|
+
profile: this.props.allowScripts ? 'trusted' : 'rich',
|
|
144
|
+
html: html,
|
|
146
145
|
ref: this.htmlContainer,
|
|
147
146
|
className: classNames(this.props.className, 'common__html-sanitizer'),
|
|
148
147
|
onClickCapture: this.handleClick
|
|
@@ -152,6 +151,7 @@ let HtmlSanitizer = /*#__PURE__*/function (_Component) {
|
|
|
152
151
|
return HtmlSanitizer;
|
|
153
152
|
}(Component);
|
|
154
153
|
HtmlSanitizer.defaultProps = {
|
|
154
|
+
allowScripts: false,
|
|
155
155
|
children: '',
|
|
156
156
|
className: '',
|
|
157
157
|
decode: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface IconProps {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* SVG markup that is sanitized and rendered inside the <svg>.
|
|
4
4
|
*/
|
|
5
5
|
content: string;
|
|
6
6
|
/**
|
|
@@ -26,7 +26,7 @@ export interface IconProps {
|
|
|
26
26
|
/**
|
|
27
27
|
* The Icon component.
|
|
28
28
|
*
|
|
29
|
-
* Renders an inline SVG icon using
|
|
29
|
+
* Renders an inline SVG icon using sanitized SVG markup.
|
|
30
30
|
*
|
|
31
31
|
* Provides basic styling via `currentColor` and supports size and color
|
|
32
32
|
* overrides through props while allowing external class-based overrides.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Icon/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Icon/index.tsx"],"names":[],"mappings":"AAWA,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,IAAI,GAAI,+CAMX,SAAS,gCAiBX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/components/Icon/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { makeStyles } from '@shopgate/engage/styles';
|
|
2
|
+
import SafeHtml from '@shopgate/engage/components/SafeHtml';
|
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
4
|
const useStyles = makeStyles()({
|
|
4
5
|
root: {
|
|
@@ -10,7 +11,7 @@ const useStyles = makeStyles()({
|
|
|
10
11
|
/**
|
|
11
12
|
* The Icon component.
|
|
12
13
|
*
|
|
13
|
-
* Renders an inline SVG icon using
|
|
14
|
+
* Renders an inline SVG icon using sanitized SVG markup.
|
|
14
15
|
*
|
|
15
16
|
* Provides basic styling via `currentColor` and supports size and color
|
|
16
17
|
* overrides through props while allowing external class-based overrides.
|
|
@@ -26,15 +27,13 @@ const Icon = ({
|
|
|
26
27
|
cx,
|
|
27
28
|
classes
|
|
28
29
|
} = useStyles();
|
|
29
|
-
return /*#__PURE__*/_jsx(
|
|
30
|
+
return /*#__PURE__*/_jsx(SafeHtml, {
|
|
31
|
+
as: "svg",
|
|
32
|
+
profile: "svg",
|
|
33
|
+
html: content,
|
|
30
34
|
className: cx(classes.root, 'common__icon', className),
|
|
31
35
|
viewBox: viewBox,
|
|
32
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
33
|
-
// eslint-disable-next-line react/no-danger
|
|
34
|
-
,
|
|
35
|
-
dangerouslySetInnerHTML: {
|
|
36
|
-
__html: content
|
|
37
|
-
},
|
|
36
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
38
37
|
style: {
|
|
39
38
|
fontSize: size,
|
|
40
39
|
fill: color
|
|
@@ -16,9 +16,10 @@ import decodeHTML from "./decodeHTML";
|
|
|
16
16
|
* are accepted.
|
|
17
17
|
* @param {boolean} [cookieConsentSettings.statisticsCookiesAccepted] Whether statistics cookies
|
|
18
18
|
* are accepted.
|
|
19
|
+
* @param {boolean} [executeScripts=true] When false, scripts are removed without running them.
|
|
19
20
|
* @returns {string} The HTML without any script tags.
|
|
20
21
|
*/
|
|
21
|
-
const parseHTML = (html, decode, settings, processStyles = false, cookieConsentSettings = {}) => {
|
|
22
|
+
const parseHTML = (html, decode, settings, processStyles = false, cookieConsentSettings = {}, executeScripts = true) => {
|
|
22
23
|
const id = CryptoJs.MD5(JSON.stringify(settings)).toString();
|
|
23
24
|
const container = getDOMContainer(`html-sanitizer-${id}`);
|
|
24
25
|
const cookieConsent = {
|
|
@@ -61,16 +62,17 @@ const parseHTML = (html, decode, settings, processStyles = false, cookieConsentS
|
|
|
61
62
|
}
|
|
62
63
|
return externalScripts;
|
|
63
64
|
};
|
|
65
|
+
if (executeScripts) {
|
|
66
|
+
// A collection of all the inline script tags.
|
|
67
|
+
inlineScripts = getInlineScripts(dom.childNodes);
|
|
68
|
+
// A collection of all the external script tags.
|
|
69
|
+
externalScripts = getExternalScripts(dom.childNodes, handleOnload);
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// Append the external scripts.
|
|
71
|
-
externalScripts.forEach(scriptTag => {
|
|
72
|
-
container.appendChild(scriptTag);
|
|
73
|
-
});
|
|
71
|
+
// Append the external scripts.
|
|
72
|
+
externalScripts.forEach(scriptTag => {
|
|
73
|
+
container.appendChild(scriptTag);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
74
76
|
if (processStyles) {
|
|
75
77
|
getStyles(dom).forEach(style => container.appendChild(style));
|
|
76
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-common",
|
|
3
|
-
"version": "7.34.0-beta.
|
|
3
|
+
"version": "7.34.0-beta.3",
|
|
4
4
|
"description": "Common library for the Shopgate Connect PWA.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Shopgate <support@shopgate.com>",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"swiper": "12.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@shopgate/pwa-core": "7.34.0-beta.
|
|
47
|
+
"@shopgate/pwa-core": "7.34.0-beta.3",
|
|
48
48
|
"@types/lodash": "^4.17.25",
|
|
49
49
|
"@types/react-portal": "^3.0.9",
|
|
50
50
|
"lodash": "^4.18.1",
|