@capillarytech/cap-ui-utils 3.0.15-alpha.1 → 3.0.15
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/index.js +0 -1
- package/package.json +1 -1
- package/utils/contentSanitizationHelper.js +7 -0
- package/utils/mfeEventBus.js +0 -47
package/index.js
CHANGED
|
@@ -12,4 +12,3 @@ export { default as sanitizeTemplateWithRegexp } from "./utils/contentSanitizati
|
|
|
12
12
|
export { default as decompressJsonObject } from "./utils/zlibDataDecompress";
|
|
13
13
|
export { default as getEnvVariable } from "./utils/getEnvVariables";
|
|
14
14
|
export { formatDateWithTimezone, getTimezoneTooltip, hasTimezoneFeatureAccess } from "./utils/timezone";
|
|
15
|
-
export { default as MFEEventBus } from "./utils/mfeEventBus";
|
package/package.json
CHANGED
|
@@ -83,9 +83,16 @@ const sanitizeTemplateWithRegexp = (content) => {
|
|
|
83
83
|
);
|
|
84
84
|
// regex to replace the ' (ascii html for apostrophe) to the apostrophe for ckeditor content
|
|
85
85
|
const apostropheRegex = new RegExp(''', 'gi');
|
|
86
|
+
// Preserve double-quote numeric HTML entities by converting them to a raw "
|
|
87
|
+
// BEFORE hexCodeRegex/regexForUnicode strips all &#…; entities. Mirrors the
|
|
88
|
+
// existing apostrophe handling above. " is harmless on its own — XSS bypass
|
|
89
|
+
// tricks like javascript: are still neutralized below because they
|
|
90
|
+
// depend on entities OTHER than "/".
|
|
91
|
+
const quoteEntityRegex = new RegExp('"|"', 'gi');
|
|
86
92
|
|
|
87
93
|
content = content
|
|
88
94
|
.replaceAll(apostropheRegex, '\'')
|
|
95
|
+
.replaceAll(quoteEntityRegex, '"')
|
|
89
96
|
.replace(hexCodeRegex, "")
|
|
90
97
|
.replace(encodedScriptTagRegex, "")
|
|
91
98
|
.replace(fullTagRegex, "")
|
package/utils/mfeEventBus.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MFEEventBus
|
|
3
|
-
*
|
|
4
|
-
* Lightweight event bus for cross-boundary communication between the MFE
|
|
5
|
-
* host shell and remote apps. Uses window CustomEvent — no build-time
|
|
6
|
-
* coupling between apps.
|
|
7
|
-
*
|
|
8
|
-
* All events are namespaced with the MFE_EVENT_PREFIX to avoid collisions
|
|
9
|
-
* with other window events (e.g. analytics, third-party libraries).
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const MFE_EVENT_PREFIX = 'mfe:';
|
|
13
|
-
|
|
14
|
-
const MFEEventBus = {
|
|
15
|
-
/**
|
|
16
|
-
* Emit an event to all listeners (host or any remote).
|
|
17
|
-
*
|
|
18
|
-
* @param {string} eventName - Event name without prefix (e.g. 'loyalty:navigate')
|
|
19
|
-
* @param {object} payload - Arbitrary serialisable data
|
|
20
|
-
*/
|
|
21
|
-
emit(eventName, payload = {}) {
|
|
22
|
-
window.dispatchEvent(
|
|
23
|
-
new CustomEvent(`${MFE_EVENT_PREFIX}${eventName}`, {
|
|
24
|
-
detail: payload,
|
|
25
|
-
bubbles: false,
|
|
26
|
-
cancelable: false,
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Subscribe to an event. Returns an unsubscribe function — call it in
|
|
33
|
-
* useEffect cleanup to prevent memory leaks.
|
|
34
|
-
*
|
|
35
|
-
* @param {string} eventName - Event name without prefix
|
|
36
|
-
* @param {function} handler - Called with the event payload object
|
|
37
|
-
* @returns {function} - Unsubscribe / cleanup function
|
|
38
|
-
*/
|
|
39
|
-
on(eventName, handler) {
|
|
40
|
-
const listener = event => handler(event.detail);
|
|
41
|
-
window.addEventListener(`${MFE_EVENT_PREFIX}${eventName}`, listener);
|
|
42
|
-
return () =>
|
|
43
|
-
window.removeEventListener(`${MFE_EVENT_PREFIX}${eventName}`, listener);
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default MFEEventBus;
|