@vrplatform/email 1.0.2-1255 → 1.0.2-1320
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/build/main/components/utils/parse-email-html.js +13 -4
- package/build/main/components/utils/parse-email-html.js.map +1 -1
- package/build/module/components/utils/parse-email-html.js +13 -4
- package/build/module/components/utils/parse-email-html.js.map +1 -1
- package/package.json +1 -1
- package/src/components/utils/parse-email-html.ts +20 -6
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseEmailHtml = void 0;
|
|
4
|
+
const escapeHtml = (value) => value
|
|
5
|
+
.replaceAll('&', '&')
|
|
6
|
+
.replaceAll('<', '<')
|
|
7
|
+
.replaceAll('>', '>')
|
|
8
|
+
.replaceAll('"', '"')
|
|
9
|
+
.replaceAll("'", ''');
|
|
4
10
|
const parseEmailHtml = (html, args) => {
|
|
5
11
|
// parse out any html scripts of type : <team-name-component></team-name-component> or <user-name-component></user-name-component>
|
|
6
12
|
// and replace them with the appropriate component
|
|
7
13
|
// return the parsed html
|
|
14
|
+
// Values are escaped because names come from users and integrations. Function
|
|
15
|
+
// replacers keep `$` sequences in a value from being read as patterns.
|
|
16
|
+
const href = escapeHtml(args.href);
|
|
8
17
|
return html
|
|
9
|
-
.replaceAll(/<action-link-component><\/action-link-component>/g, `<a href="${
|
|
10
|
-
.replaceAll(/<user-name-component><\/user-name-component>/g, args.userName)
|
|
11
|
-
.replaceAll(/<listing-name-component><\/listing-name-component>/g, args.listingName)
|
|
12
|
-
.replaceAll(/<date-component><\/date-component>/g, args.date);
|
|
18
|
+
.replaceAll(/<action-link-component><\/action-link-component>/g, () => `<a href="${href}" target="_blank">${href}</a>`)
|
|
19
|
+
.replaceAll(/<user-name-component><\/user-name-component>/g, () => escapeHtml(args.userName))
|
|
20
|
+
.replaceAll(/<listing-name-component><\/listing-name-component>/g, () => escapeHtml(args.listingName))
|
|
21
|
+
.replaceAll(/<date-component><\/date-component>/g, () => escapeHtml(args.date));
|
|
13
22
|
};
|
|
14
23
|
exports.parseEmailHtml = parseEmailHtml;
|
|
15
24
|
//# sourceMappingURL=parse-email-html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-email-html.js","sourceRoot":"src/","sources":["components/utils/parse-email-html.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"parse-email-html.js","sourceRoot":"src/","sources":["components/utils/parse-email-html.ts"],"names":[],"mappings":";;;AAAA,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,KAAK;KACF,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAEvB,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,IAKC,EACD,EAAE;IACF,kIAAkI;IAClI,kDAAkD;IAClD,yBAAyB;IACzB,8EAA8E;IAC9E,uEAAuE;IACvE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,IAAI;SACR,UAAU,CACT,mDAAmD,EACnD,GAAG,EAAE,CAAC,YAAY,IAAI,qBAAqB,IAAI,MAAM,CACtD;SACA,UAAU,CAAC,+CAA+C,EAAE,GAAG,EAAE,CAChE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC1B;SACA,UAAU,CAAC,qDAAqD,EAAE,GAAG,EAAE,CACtE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B;SACA,UAAU,CAAC,qCAAqC,EAAE,GAAG,EAAE,CACtD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CACtB,CAAC;AACN,CAAC,CAAC;AA9BW,QAAA,cAAc,kBA8BzB","sourcesContent":["const escapeHtml = (value: string) =>\n value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n\nexport const parseEmailHtml = (\n html: string,\n args: {\n href: string;\n userName: string;\n listingName: string;\n date: string;\n }\n) => {\n // parse out any html scripts of type : <team-name-component></team-name-component> or <user-name-component></user-name-component>\n // and replace them with the appropriate component\n // return the parsed html\n // Values are escaped because names come from users and integrations. Function\n // replacers keep `$` sequences in a value from being read as patterns.\n const href = escapeHtml(args.href);\n\n return html\n .replaceAll(\n /<action-link-component><\\/action-link-component>/g,\n () => `<a href=\"${href}\" target=\"_blank\">${href}</a>`\n )\n .replaceAll(/<user-name-component><\\/user-name-component>/g, () =>\n escapeHtml(args.userName)\n )\n .replaceAll(/<listing-name-component><\\/listing-name-component>/g, () =>\n escapeHtml(args.listingName)\n )\n .replaceAll(/<date-component><\\/date-component>/g, () =>\n escapeHtml(args.date)\n );\n};\n"]}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
const escapeHtml = (value) => value
|
|
2
|
+
.replaceAll('&', '&')
|
|
3
|
+
.replaceAll('<', '<')
|
|
4
|
+
.replaceAll('>', '>')
|
|
5
|
+
.replaceAll('"', '"')
|
|
6
|
+
.replaceAll("'", ''');
|
|
1
7
|
export const parseEmailHtml = (html, args) => {
|
|
2
8
|
// parse out any html scripts of type : <team-name-component></team-name-component> or <user-name-component></user-name-component>
|
|
3
9
|
// and replace them with the appropriate component
|
|
4
10
|
// return the parsed html
|
|
11
|
+
// Values are escaped because names come from users and integrations. Function
|
|
12
|
+
// replacers keep `$` sequences in a value from being read as patterns.
|
|
13
|
+
const href = escapeHtml(args.href);
|
|
5
14
|
return html
|
|
6
|
-
.replaceAll(/<action-link-component><\/action-link-component>/g, `<a href="${
|
|
7
|
-
.replaceAll(/<user-name-component><\/user-name-component>/g, args.userName)
|
|
8
|
-
.replaceAll(/<listing-name-component><\/listing-name-component>/g, args.listingName)
|
|
9
|
-
.replaceAll(/<date-component><\/date-component>/g, args.date);
|
|
15
|
+
.replaceAll(/<action-link-component><\/action-link-component>/g, () => `<a href="${href}" target="_blank">${href}</a>`)
|
|
16
|
+
.replaceAll(/<user-name-component><\/user-name-component>/g, () => escapeHtml(args.userName))
|
|
17
|
+
.replaceAll(/<listing-name-component><\/listing-name-component>/g, () => escapeHtml(args.listingName))
|
|
18
|
+
.replaceAll(/<date-component><\/date-component>/g, () => escapeHtml(args.date));
|
|
10
19
|
};
|
|
11
20
|
//# sourceMappingURL=parse-email-html.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-email-html.js","sourceRoot":"src/","sources":["components/utils/parse-email-html.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,IAKC,EACD,EAAE;IACF,kIAAkI;IAClI,kDAAkD;IAClD,yBAAyB;
|
|
1
|
+
{"version":3,"file":"parse-email-html.js","sourceRoot":"src/","sources":["components/utils/parse-email-html.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CACnC,KAAK;KACF,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;KACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;KACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;KACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAE9B,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,IAKC,EACD,EAAE;IACF,kIAAkI;IAClI,kDAAkD;IAClD,yBAAyB;IACzB,8EAA8E;IAC9E,uEAAuE;IACvE,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,IAAI;SACR,UAAU,CACT,mDAAmD,EACnD,GAAG,EAAE,CAAC,YAAY,IAAI,qBAAqB,IAAI,MAAM,CACtD;SACA,UAAU,CAAC,+CAA+C,EAAE,GAAG,EAAE,CAChE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC1B;SACA,UAAU,CAAC,qDAAqD,EAAE,GAAG,EAAE,CACtE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B;SACA,UAAU,CAAC,qCAAqC,EAAE,GAAG,EAAE,CACtD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CACtB,CAAC;AACN,CAAC,CAAC","sourcesContent":["const escapeHtml = (value: string) =>\n value\n .replaceAll('&', '&')\n .replaceAll('<', '<')\n .replaceAll('>', '>')\n .replaceAll('\"', '"')\n .replaceAll(\"'\", ''');\n\nexport const parseEmailHtml = (\n html: string,\n args: {\n href: string;\n userName: string;\n listingName: string;\n date: string;\n }\n) => {\n // parse out any html scripts of type : <team-name-component></team-name-component> or <user-name-component></user-name-component>\n // and replace them with the appropriate component\n // return the parsed html\n // Values are escaped because names come from users and integrations. Function\n // replacers keep `$` sequences in a value from being read as patterns.\n const href = escapeHtml(args.href);\n\n return html\n .replaceAll(\n /<action-link-component><\\/action-link-component>/g,\n () => `<a href=\"${href}\" target=\"_blank\">${href}</a>`\n )\n .replaceAll(/<user-name-component><\\/user-name-component>/g, () =>\n escapeHtml(args.userName)\n )\n .replaceAll(/<listing-name-component><\\/listing-name-component>/g, () =>\n escapeHtml(args.listingName)\n )\n .replaceAll(/<date-component><\\/date-component>/g, () =>\n escapeHtml(args.date)\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
const escapeHtml = (value: string) =>
|
|
2
|
+
value
|
|
3
|
+
.replaceAll('&', '&')
|
|
4
|
+
.replaceAll('<', '<')
|
|
5
|
+
.replaceAll('>', '>')
|
|
6
|
+
.replaceAll('"', '"')
|
|
7
|
+
.replaceAll("'", ''');
|
|
8
|
+
|
|
1
9
|
export const parseEmailHtml = (
|
|
2
10
|
html: string,
|
|
3
11
|
args: {
|
|
@@ -10,16 +18,22 @@ export const parseEmailHtml = (
|
|
|
10
18
|
// parse out any html scripts of type : <team-name-component></team-name-component> or <user-name-component></user-name-component>
|
|
11
19
|
// and replace them with the appropriate component
|
|
12
20
|
// return the parsed html
|
|
21
|
+
// Values are escaped because names come from users and integrations. Function
|
|
22
|
+
// replacers keep `$` sequences in a value from being read as patterns.
|
|
23
|
+
const href = escapeHtml(args.href);
|
|
13
24
|
|
|
14
25
|
return html
|
|
15
26
|
.replaceAll(
|
|
16
27
|
/<action-link-component><\/action-link-component>/g,
|
|
17
|
-
`<a href="${
|
|
28
|
+
() => `<a href="${href}" target="_blank">${href}</a>`
|
|
18
29
|
)
|
|
19
|
-
.replaceAll(/<user-name-component><\/user-name-component>/g,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
.replaceAll(/<user-name-component><\/user-name-component>/g, () =>
|
|
31
|
+
escapeHtml(args.userName)
|
|
32
|
+
)
|
|
33
|
+
.replaceAll(/<listing-name-component><\/listing-name-component>/g, () =>
|
|
34
|
+
escapeHtml(args.listingName)
|
|
23
35
|
)
|
|
24
|
-
.replaceAll(/<date-component><\/date-component>/g,
|
|
36
|
+
.replaceAll(/<date-component><\/date-component>/g, () =>
|
|
37
|
+
escapeHtml(args.date)
|
|
38
|
+
);
|
|
25
39
|
};
|