YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
test(chat): cover img onerror, svg onload and script in raw HTML
Manas Raghuwanshi20174c17f141
diff --git a/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsx b/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsxindex 58c703af1..aa635bb2d 100644--- a/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsx+++ b/apps/screenpipe-app-tauri/components/chat/markdown-block.test.tsx@@ -400,6 +400,22 @@ describe("MarkdownBlock", () => {expect(container).toHaveTextContent("after");});+ it.each([+ ["img onerror", `<img src=x onerror=alert(1)>`],+ ["svg onload", `<svg onload=alert(1)><circle r=1></circle></svg>`],+ ["script", `<script>alert(1)</script>`],+ ])("drops %s before it reaches React", (_name, html) => {+ const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});+ const container = renderHtml(html);+ expect(container.querySelector("[onerror], [onload], svg, script")).toBeNull();+ // React silently drops string handlers from the DOM, so the DOM alone+ // cannot prove sanitization; its warning shows the handler got through.+ expect(+ consoleError.mock.calls.filter(([msg]) => String(msg).includes("listener to be a function")),+ ).toEqual([]);+ consoleError.mockRestore();+ });+it("strips inline styles from allowed tags", () => {const container = renderHtml(`<b style="position:fixed;inset:0">bold</b>`);const bold = container.querySelector("b");