@vrplatform/email 1.0.2-1285 → 1.0.2-1322

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.
@@ -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('<', '&lt;')
7
+ .replaceAll('>', '&gt;')
8
+ .replaceAll('"', '&quot;')
9
+ .replaceAll("'", '&#39;');
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="${args.href}" target="_blank">${args.href}</a>`)
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":";;;AAAO,MAAM,cAAc,GAAG,CAC5B,IAAY,EACZ,IAKC,EACD,EAAE;IACF,kIAAkI;IAClI,kDAAkD;IAClD,yBAAyB;IAEzB,OAAO,IAAI;SACR,UAAU,CACT,mDAAmD,EACnD,YAAY,IAAI,CAAC,IAAI,qBAAqB,IAAI,CAAC,IAAI,MAAM,CAC1D;SACA,UAAU,CAAC,+CAA+C,EAAE,IAAI,CAAC,QAAQ,CAAC;SAC1E,UAAU,CACT,qDAAqD,EACrD,IAAI,CAAC,WAAW,CACjB;SACA,UAAU,CAAC,qCAAqC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC,CAAC;AAxBW,QAAA,cAAc,kBAwBzB","sourcesContent":["export 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\n return html\n .replaceAll(\n /<action-link-component><\\/action-link-component>/g,\n `<a href=\"${args.href}\" target=\"_blank\">${args.href}</a>`\n )\n .replaceAll(/<user-name-component><\\/user-name-component>/g, args.userName)\n .replaceAll(\n /<listing-name-component><\\/listing-name-component>/g,\n args.listingName\n )\n .replaceAll(/<date-component><\\/date-component>/g, args.date);\n};\n"]}
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('&', '&amp;')\n .replaceAll('<', '&lt;')\n .replaceAll('>', '&gt;')\n .replaceAll('\"', '&quot;')\n .replaceAll(\"'\", '&#39;');\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('&', '&amp;')
3
+ .replaceAll('<', '&lt;')
4
+ .replaceAll('>', '&gt;')
5
+ .replaceAll('"', '&quot;')
6
+ .replaceAll("'", '&#39;');
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="${args.href}" target="_blank">${args.href}</a>`)
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;IAEzB,OAAO,IAAI;SACR,UAAU,CACT,mDAAmD,EACnD,YAAY,IAAI,CAAC,IAAI,qBAAqB,IAAI,CAAC,IAAI,MAAM,CAC1D;SACA,UAAU,CAAC,+CAA+C,EAAE,IAAI,CAAC,QAAQ,CAAC;SAC1E,UAAU,CACT,qDAAqD,EACrD,IAAI,CAAC,WAAW,CACjB;SACA,UAAU,CAAC,qCAAqC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC,CAAC","sourcesContent":["export 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\n return html\n .replaceAll(\n /<action-link-component><\\/action-link-component>/g,\n `<a href=\"${args.href}\" target=\"_blank\">${args.href}</a>`\n )\n .replaceAll(/<user-name-component><\\/user-name-component>/g, args.userName)\n .replaceAll(\n /<listing-name-component><\\/listing-name-component>/g,\n args.listingName\n )\n .replaceAll(/<date-component><\\/date-component>/g, args.date);\n};\n"]}
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('&', '&amp;')\n .replaceAll('<', '&lt;')\n .replaceAll('>', '&gt;')\n .replaceAll('\"', '&quot;')\n .replaceAll(\"'\", '&#39;');\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,6 +1,6 @@
1
1
  {
2
2
  "name": "@vrplatform/email",
3
- "version": "1.0.2-1285",
3
+ "version": "1.0.2-1322",
4
4
  "description": "VRTrust transactional email templates and Postmark transport",
5
5
  "license": "ISC",
6
6
  "main": "build/main/index.js",
@@ -1,3 +1,11 @@
1
+ const escapeHtml = (value: string) =>
2
+ value
3
+ .replaceAll('&', '&amp;')
4
+ .replaceAll('<', '&lt;')
5
+ .replaceAll('>', '&gt;')
6
+ .replaceAll('"', '&quot;')
7
+ .replaceAll("'", '&#39;');
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="${args.href}" target="_blank">${args.href}</a>`
28
+ () => `<a href="${href}" target="_blank">${href}</a>`
18
29
  )
19
- .replaceAll(/<user-name-component><\/user-name-component>/g, args.userName)
20
- .replaceAll(
21
- /<listing-name-component><\/listing-name-component>/g,
22
- args.listingName
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, args.date);
36
+ .replaceAll(/<date-component><\/date-component>/g, () =>
37
+ escapeHtml(args.date)
38
+ );
25
39
  };