feat(email-renderer): compile safe semantic styles
This commit is contained in:
1 parent
353cadda60
commit
2428df6e78
3 files changed
+49
-2
No files matched your search
@@ -73,6 +73,23 @@ describe("email renderer", () => {
|
||||
expect((await validateAmpEmail("<html></html>")).valid).toBe(false);
|
||||
});
|
||||
|
||||
test("compiles only allowlisted semantic styles", async () => {
|
||||
const styled = structuredClone(document);
|
||||
styled.root.slots.content[0]!.slots.content[0]!.styles = {
|
||||
color: { base: "#123456" },
|
||||
textAlign: { base: "center" },
|
||||
padding: { base: "12px 8px" },
|
||||
backgroundColor: { base: "red;position:fixed" },
|
||||
};
|
||||
const rendered = await renderEmail(styled);
|
||||
expect(rendered.ok).toBe(true);
|
||||
if (!rendered.ok) return;
|
||||
expect(rendered.value.parts.html.content).toContain(
|
||||
"color:#123456;padding:12px 8px;text-align:center",
|
||||
);
|
||||
expect(rendered.value.parts.html.content).not.toContain("position:fixed");
|
||||
});
|
||||
|
||||
test("rejects unsafe MJML and imports supported content", () => {
|
||||
expect(
|
||||
importMjml("<mjml><mj-body><mj-raw>x</mj-raw></mj-body></mjml>", {
|
||||
|
||||
Reference in new issue
Block a user