diff --git a/apps/server/src/workspaces/logo.test.ts b/apps/server/src/workspaces/logo.test.ts
index 1eab123..0f1fb0b 100644
--- a/apps/server/src/workspaces/logo.test.ts
+++ b/apps/server/src/workspaces/logo.test.ts
@@ -22,6 +22,62 @@ describe("sanitizeSvg", () => {
const out = sanitizeSvg(Buffer.from(dirty)).toString("utf8");
expect(out).not.toMatch(/foreignObject/i);
});
+
+ // Vectors the earlier regex-based sanitizer let through. The parser-based implementation
+ // blocks all of them; these cases exist so a "simplification" back to regexes fails CI
+ // rather than silently reopening the holes.
+ describe("vectors that defeat naive regex stripping", () => {
+ it("strips an unquoted javascript: href", () => {
+ const out = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(out).not.toMatch(/javascript:/i);
+ expect(out).toContain(" {
+ const out = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(out).not.toMatch(/javascript:/i);
+ });
+
+ it("strips a javascript: href broken up by control characters", () => {
+ const out = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(out).not.toMatch(/script:/i);
+ });
+
+ it.each(["iframe", "embed", "object", "video", "audio", "canvas"])("strips <%s>", (tag) => {
+ const out = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(out.toLowerCase()).not.toContain(`<${tag}`);
+ expect(out).not.toContain("evil.test");
+ expect(out).toContain("", () => {
+ const out = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(out).not.toMatch(/foreignObject/i);
+ expect(out).toContain(" {
+ const out = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(out).not.toMatch(/style=/i);
+ expect(out).not.toContain("evil.test");
+ });
+
+ it("strips an external xlink:href while keeping same-document fragments", () => {
+ const external = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(external).not.toContain("evil.test");
+
+ const internal = sanitizeSvg(Buffer.from(``)).toString("utf8");
+ expect(internal).toContain("#gradient");
+ });
+
+ it("keeps ordinary drawing markup intact", () => {
+ const clean = ``;
+ const out = sanitizeSvg(Buffer.from(clean)).toString("utf8");
+ expect(out).toContain("viewBox=\"0 0 24 24\"");
+ expect(out).toContain("d=\"M4 4h16v16H4z\"");
+ expect(out).toContain("fill=\"#123456\"");
+ });
+ });
});
describe("workspaceLogoUrl", () => {