phx-node 1.0.97 → 1.0.98
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.
|
@@ -5,29 +5,30 @@ const liquidjs_1 = require("liquidjs");
|
|
|
5
5
|
const PHXAllowTags = (html) => {
|
|
6
6
|
const allowedTags = ["p", "b", "i", "a", "br"];
|
|
7
7
|
const tagRegex = /<\/?([a-zA-Z0-9]+)(\s[^>]*)?>/g;
|
|
8
|
-
|
|
8
|
+
let match;
|
|
9
|
+
while ((match = tagRegex.exec(html)) !== null) {
|
|
10
|
+
const [_fullMatch, tagName, attrs] = match;
|
|
9
11
|
const lowerTag = tagName.toLowerCase();
|
|
10
12
|
if (!allowedTags.includes(lowerTag)) {
|
|
11
13
|
throw new Error(`Tag <${lowerTag}> is not allowed`);
|
|
12
14
|
}
|
|
13
|
-
if (
|
|
14
|
-
return `<${lowerTag}>`;
|
|
15
|
-
if (/class\s*=|style\s*=|on[a-z]+\s*=/i.test(attrs)) {
|
|
15
|
+
if (attrs && /class\s*=|style\s*=|on[a-z]+\s*=/i.test(attrs)) {
|
|
16
16
|
throw new Error(`Tag <${lowerTag}> contains forbidden attributes (class/style/event)`);
|
|
17
17
|
}
|
|
18
18
|
if (lowerTag === "a") {
|
|
19
|
-
const hrefMatch = attrs.match(/\s*href\s*=\s*(['"])(.*?)\1/i);
|
|
19
|
+
const hrefMatch = attrs === null || attrs === void 0 ? void 0 : attrs.match(/\s*href\s*=\s*(['"])(.*?)\1/i);
|
|
20
20
|
if (!hrefMatch) {
|
|
21
21
|
throw new Error(`<a> tag must have valid href`);
|
|
22
22
|
}
|
|
23
|
-
return `<a href="${hrefMatch[2]}">`;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (attrs && lowerTag !== "a") {
|
|
25
|
+
const cleanedAttrs = attrs.trim();
|
|
26
|
+
if (cleanedAttrs) {
|
|
27
|
+
throw new Error(`Tag <${lowerTag}> should not have attributes`);
|
|
28
|
+
}
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
}
|
|
31
|
+
return html;
|
|
31
32
|
};
|
|
32
33
|
exports.PHXAllowTags = PHXAllowTags;
|
|
33
34
|
const PHXEmailRenderToHTML = (html, obj) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-render-to-HTML.js","sourceRoot":"","sources":["../../../src/lib/utils/email-render-to-HTML.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAM3B,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE;IACnD,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,gCAAgC,CAAC;IAElD,
|
|
1
|
+
{"version":3,"file":"email-render-to-HTML.js","sourceRoot":"","sources":["../../../src/lib/utils/email-render-to-HTML.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAM3B,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EAAE;IACnD,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,gCAAgC,CAAC;IAElD,IAAI,KAA6B,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;QAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAEvC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,kBAAkB,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,KA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