Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): sanitize preview tab titles at the workspaceTabs store border
Diego Zacariasda81b9497847
diff --git a/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts b/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.tsindex 124de878e..2dbe57764 100644--- a/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts+++ b/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts@@ -402,6 +402,24 @@ describe('workspaceTabs — preview multi-instance by gfsUri (spec 18 §3.B.1)',})})+ it('sanitizes an externally-controlled file name at the preview store border', () => {+ let state = createEmptyWorkspaceTabsState()+ // A GFS file name carrying a bidi override + zero-width must not reach the tab+ // chrome raw — same threat class as a plugin document.title.+ state = openPreviewTab(state, previewInput('p-evil', 'gfs://main/evil', `report.png`))+ const created = state.tabs.find(t => t.id === 'p-evil')+ expect(created?.title).toBe('report.png')++ // A name that reduces to empty after sanitizing falls back to 'Preview',+ // never a blank tab label.+ state = openPreviewTab(state, previewInput('p-blank', 'gfs://main/blank', ``))+ expect(state.tabs.find(t => t.id === 'p-blank')?.title).toBe('Preview')++ // The same cleaning applies when a re-open aligns the title of an existing tab.+ state = openPreviewTab(state, previewInput('p-evil2', 'gfs://main/evil', `clean.png`))+ expect(state.tabs.find(t => t.preview?.gfsUri === 'gfs://main/evil')?.title).toBe('clean.png')+ })+it('omits mimeType from the payload when absent (markdown has none)', () => {let state = createEmptyWorkspaceTabsState()state = openPreviewTab(state, {diff --git a/desktop-app/ui/src/lib/workspaceTabs.ts b/desktop-app/ui/src/lib/workspaceTabs.tsindex 21755f597..c9afd5c95 100644--- a/desktop-app/ui/src/lib/workspaceTabs.ts+++ b/desktop-app/ui/src/lib/workspaceTabs.ts@@ -298,7 +298,12 @@ export function openPreviewTab(const existing = state.tabs.find(tab => tab.kind === 'preview' && tab.preview?.gfsUri === input.gfsUri)- const title = input.title?.trim()+ // A preview tab's title is a GFS file name — externally-controlled input in the+ // same threat class as a plugin's document.title (control chars, bidi overrides,+ // zero-width, unbounded length), so it goes through the shared tab-title+ // sanitizer at this single store border; every render site inherits the cleaned+ // value. Empty-after-sanitize falls back to 'Preview' below.+ const title = input.title ? sanitizeAppTabTitle(input.title) : ''if (existing) {return {tabs: