import { describe, expect, test } from "vitest"; import { sanitizeInlineHtml } from "./inline"; // Payload from GHSA-h73g-85mv-f42f: a full-screen overlay with a phishing link. const OVERLAY_PAYLOAD = `

This recipe has been removed. Click here.

`; describe("sanitizeInlineHtml", () => { test("returns empty string for nullish input", () => { expect(sanitizeInlineHtml(null)).toEqual(""); expect(sanitizeInlineHtml(undefined)).toEqual(""); expect(sanitizeInlineHtml("")).toEqual(""); }); test("keeps fraction formatting", () => { expect(sanitizeInlineHtml("11⁄2")).toEqual( "11⁄2", ); }); test("keeps emphasis tags", () => { expect(sanitizeInlineHtml("a b c d")).toEqual( "a b c d", ); }); test("strips block elements, links, images, and styles from the overlay payload", () => { const html = sanitizeInlineHtml(OVERLAY_PAYLOAD); for (const fragment of [" { expect(sanitizeInlineHtml("a")).toEqual( "a", ); }); });