")).toBe(
""
);
expect(
editor.shared.sanitize.sanitize("abc
")
).toBe("abc
");
});
test("sanitize should leave t-field, t-out, t-esc as is", async () => {
const { editor } = await setupEditor("");
expect(editor.shared.sanitize.sanitize(``)).toBe(
''
);
expect(editor.shared.sanitize.sanitize(``)).toBe(
''
);
expect(editor.shared.sanitize.sanitize(``)).toBe(
''
);
});
test("sanitize plugin should handle contenteditable attribute with o-contenteditable-[true/false] class", async () => {
await testEditor({
contentBefore: `a[]
b
`,
contentAfterEdit: `a[]
b
`,
contentAfter: `a[]
b
`,
});
});
test("sanitize plugin should handle role attribute with data-oe-role attribute", async () => {
await testEditor({
contentBefore: `a[]
`,
contentAfterEdit: `a[]
`,
contentAfter: `a[]
`,
});
});
test("sanitize plugin should handle aria-label attribute with data-oe-aria-label attribute", async () => {
await testEditor({
contentBefore: `a[]
`,
contentAfterEdit: `a[]
`,
contentAfter: `a[]
`,
});
});
test("fixInvalidHTML should close self-closing elements", () => {
expect(fixInvalidHTML(markup``).toString()).toBe("");
expect(fixInvalidHTML(markup``).toString()).toBe('');
expect(fixInvalidHTML(markup``).toString()).toBe("");
expect(fixInvalidHTML(markup``).toString()).toBe('');
expect(fixInvalidHTML(markup``).toString()).toBe("");
expect(fixInvalidHTML(markup``).toString()).toBe(
''
);
expect(fixInvalidHTML(markup``).toString()).toBe("");
expect(fixInvalidHTML(markup``).toString()).toBe('');
expect(
fixInvalidHTML(
markup`asdf`
).toString()
).toBe('asdf');
});
test("fixInvalidHTML escapes string input", () => {
expect(fixInvalidHTML("").toString()).toBe("<t/>");
expect(fixInvalidHTML('').toString()).toBe(
"<a href="?param=value&other=test"/>"
);
});
test("fixInvalidHTML should return markup", () => {
expect(fixInvalidHTML(markup``)).toBeInstanceOf(Markup);
expect(fixInvalidHTML("")).toBeInstanceOf(Markup);
});
test("fixInvalidHTML handles nested self-closing tags correctly", () => {
expect(fixInvalidHTML(markup``).toString()).toBe(
""
);
expect(fixInvalidHTML(markup``).toString()).toBe(
''
);
});
test("fixInvalidHTML preserves escaped content in attributes and text", () => {
expect(fixInvalidHTML(markup``).toString()).toBe(
``
);
expect(fixInvalidHTML(markup`Text with <escaped> content
`).toString()).toBe(
`Text with <escaped> content
`
);
});
test("fixInvalidHTML attribute", () => {
// Properly quoted attributes should work
expect(fixInvalidHTML(markup``).toString()).toBe(
``
);
// Unclosed quotes should NOT be converted (security protection)
expect(fixInvalidHTML(markup``);
// Mismatched quotes should NOT be converted (security protection)
expect(fixInvalidHTML(markup``);
// Valid data attributes with special characters should work
expect(fixInvalidHTML(markup``).toString()).toBe(
``
);
// Attributes with invalid characters in unquoted values should NOT match
expect(fixInvalidHTML(markup`value/>`).toString()).toBe(`value/>`);
// Attributes containing < or > characters in quoted values should work
expect(fixInvalidHTML(markup``).toString()).toBe(
``
);
expect(fixInvalidHTML(markup``).toString()).toBe(
``
);
});