diff options
Diffstat (limited to 'apps/web/lib/sanitize.test.ts')
| -rw-r--r-- | apps/web/lib/sanitize.test.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/apps/web/lib/sanitize.test.ts b/apps/web/lib/sanitize.test.ts index 266b8af..f47db80 100644 --- a/apps/web/lib/sanitize.test.ts +++ b/apps/web/lib/sanitize.test.ts @@ -44,4 +44,50 @@ describe("sanitizeEntryContent", () => { const input = "<pre><code>const x = 1</code></pre>" expect(sanitizeEntryContent(input)).toBe(input) }) + + it("strips 1x1 tracking pixel images", () => { + const input = '<p>content</p><img src="https://tracker.example.com/pixel.gif" width="1" height="1">' + expect(sanitizeEntryContent(input)).toBe("<p>content</p>") + }) + + it("strips images with zero dimensions", () => { + const input = '<img src="https://tracker.example.com/pixel.gif" width="0" height="0">' + expect(sanitizeEntryContent(input)).toBe("") + }) + + it("strips images where only width is a tracking dimension", () => { + const input = '<img src="https://tracker.example.com/pixel.gif" width="1">' + expect(sanitizeEntryContent(input)).toBe("") + }) + + it("strips images where only height is a tracking dimension", () => { + const input = '<img src="https://tracker.example.com/pixel.gif" height="2">' + expect(sanitizeEntryContent(input)).toBe("") + }) + + it("preserves normal-sized images", () => { + const input = '<img src="https://example.com/photo.jpg" width="800" height="600">' + const result = sanitizeEntryContent(input) + expect(result).toContain("src=") + expect(result).toContain("width=") + expect(result).toContain("height=") + }) + + it("preserves images without dimension attributes", () => { + const input = '<img src="https://example.com/photo.jpg" alt="a photo">' + const result = sanitizeEntryContent(input) + expect(result).toContain("src=") + expect(result).toContain("alt=") + }) + + it("strips 3x3 tracking pixel at threshold boundary", () => { + const input = '<img src="https://tracker.example.com/pixel.gif" width="3" height="3">' + expect(sanitizeEntryContent(input)).toBe("") + }) + + it("preserves images just above tracking pixel threshold", () => { + const input = '<img src="https://example.com/icon.png" width="4" height="4">' + const result = sanitizeEntryContent(input) + expect(result).toContain("src=") + }) }) |