Prevent Markdown image loading#640
Conversation
📝 WalkthroughWalkthroughMarkdownContent now suppresses Markdown image elements, rendering alt text when present. Tests cover remote, relative, data, and blob image URLs, plus standard Markdown links. ChangesMarkdown rendering
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/components/markdown.test.ts (1)
11-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the empty-alt branch.
markdown.tsxreturnsnullwhen alt text is empty or missing, but this test only exercises non-empty alt text. Add acase and assert that neither the URL,<img>, nor an alt-text<span>is rendered.Suggested test
+ it("omits images with no alt text", () => { + const rendered = renderMarkdown(""); + + expect(rendered).not.toContain("<img"); + expect(rendered).not.toContain("hidden.png"); + expect(rendered).not.toContain("<span"); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/components/markdown.test.ts` around lines 11 - 31, Extend the “MarkdownContent images” test to include an image with empty alt text, such as . Assert the rendered output excludes the image URL, <img>, and alt-text <span>, covering the null-return branch in markdown.tsx.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@frontend/src/components/markdown.test.ts`:
- Around line 11-31: Extend the “MarkdownContent images” test to include an
image with empty alt text, such as . Assert
the rendered output excludes the image URL, <img>, and alt-text <span>, covering
the null-return branch in markdown.tsx.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3e43913c-268c-4f9f-b6b1-c63fc0edf6c4
📒 Files selected for processing (2)
frontend/src/components/markdown.test.tsfrontend/src/components/markdown.tsx
Deploying maple with
|
| Latest commit: |
afd3bbf
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7143667a.maple-ca8.pages.dev |
| Branch Preview URL: | https://codex-kagi-search-provider-m.maple-ca8.pages.dev |
Summary
Companion backend work: OpenSecretCloud/opensecret#237 sanitizes Kagi-provided Markdown before content budgets and safe truncation.
Validation