Skip to content

The open-source app everyone uses to manage agents at work

Guard markdown filename previews by content type

Dotta2997a47fec54
diff --git a/ui/src/components/IssueAttachmentsSection.test.tsx b/ui/src/components/IssueAttachmentsSection.test.tsx
index 6fca448a89..d9c3ff1b56 100644
--- a/ui/src/components/IssueAttachmentsSection.test.tsx
+++ b/ui/src/components/IssueAttachmentsSection.test.tsx
@@ -153,6 +153,35 @@ describe("IssueAttachmentsSection", () => {
});
});
+ it("does not promote specific non-markdown content types by filename alone", async () => {
+ const attachment = makeAttachment({
+ id: "zip-markdown",
+ originalFilename: "report.md",
+ contentType: "application/zip",
+ contentPath: "/api/attachments/zip-markdown/content",
+ openPath: "/api/attachments/zip-markdown/content",
+ downloadPath: "/api/attachments/zip-markdown/content?download=1",
+ });
+
+ await act(async () => {
+ root.render(
+ <QueryClientProvider client={queryClient}>
+ <IssueAttachmentsSection
+ attachments={[attachment]}
+ onDelete={vi.fn()}
+ onImageClick={vi.fn()}
+ />
+ </QueryClientProvider>,
+ );
+ });
+ await flushReact();
+
+ expect(container.querySelector('[data-testid="markdown-body"]')).toBeNull();
+ expect(container.textContent).toContain("report.md");
+ expect(container.textContent).toContain("application/zip");
+ expect(fetchSpy).not.toHaveBeenCalled();
+ });
+
it("renders video attachments through the same player used for artifact outputs", async () => {
const attachment = makeAttachment({
id: "video-attachment",
diff --git a/ui/src/lib/issue-attachments.ts b/ui/src/lib/issue-attachments.ts
index 39534d483b..8c6859dadc 100644
--- a/ui/src/lib/issue-attachments.ts
+++ b/ui/src/lib/issue-attachments.ts
@@ -63,5 +63,6 @@ export function isMarkdownAttachment(
}
const filename = (attachment.originalFilename ?? "").toLowerCase();
- return filename.endsWith(".md") || filename.endsWith(".markdown");
+ if (!filename.endsWith(".md") && !filename.endsWith(".markdown")) return false;
+ return contentType === "text/plain" || GENERIC_ATTACHMENT_CONTENT_TYPES.has(contentType);
}