Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(desktop): sanitize files tab titles at the setFilesTabPath store border

Diego Zacarias74ac9bd65ec4
diff --git a/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts b/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts
index 2dbe57764..0f8e73dd2 100644
--- a/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts
+++ b/desktop-app/ui/src/lib/__tests__/workspaceTabs.test.ts
@@ -304,6 +304,18 @@ describe('workspaceTabs — files multi-instance by path (mini-spec 06 §3)', ()
expect(rooted?.title).toBe('Files')
})
+ it('sanitizes an externally-controlled folder name at the files store border', () => {
+ let state = createEmptyWorkspaceTabsState()
+ state = openFilesTab(state, { id: 'f-1', path: null })
+ // A GFS folder name carrying a bidi override + zero-width is the same threat
+ // class as a preview file name — it must not reach the tab chrome raw.
+ state = setFilesTabPath(state, 'f-1', 'gfs://main/ccc', `In‮voices​`)
+ expect(state.tabs.find(t => t.id === 'f-1')?.title).toBe('Invoices')
+ // A folder name that reduces to empty after sanitizing falls back to 'Files'.
+ state = setFilesTabPath(state, 'f-1', 'gfs://main/blank', `‮​`)
+ expect(state.tabs.find(t => t.id === 'f-1')?.title).toBe('Files')
+ })
+
it('setFilesTabPath is a no-op (same ref) when nothing moved, or the tab is missing / not files', () => {
let state = createEmptyWorkspaceTabsState()
state = openFilesTab(state, { id: 'f-1', path: 'gfs://main/aaa', title: 'Reports' })
diff --git a/desktop-app/ui/src/lib/workspaceTabs.ts b/desktop-app/ui/src/lib/workspaceTabs.ts
index c9afd5c95..fadefc131 100644
--- a/desktop-app/ui/src/lib/workspaceTabs.ts
+++ b/desktop-app/ui/src/lib/workspaceTabs.ts
@@ -263,7 +263,10 @@ export function openFilesTab(
* out. It does NOT re-dedupe — dedupe is an open-time rule only (§3).
*
* `title` is the current folder's display name (which the opaque `gfsUri` does
- * not carry), supplied by the browser; absent / empty ⇒ 'Files'.
+ * not carry), supplied by the browser; absent / empty ⇒ 'Files'. It is a GFS
+ * folder name — externally-controlled input in the same threat class as a
+ * preview tab's file name — so it passes through the shared tab-title sanitizer
+ * at this store border (mirrors `openPreviewTab` / `setAppTabTitle`).
*/
export function setFilesTabPath(
state: WorkspaceTabsState,
@@ -274,7 +277,7 @@ export function setFilesTabPath(
const target = state.tabs.find(tab => tab.id === tabId && tab.kind === 'files')
if (!target) return state
const nextPath = path ?? null
- const nextTitle = title?.trim() || 'Files'
+ const nextTitle = (title ? sanitizeAppTabTitle(title) : '') || 'Files'
if ((target.files?.path ?? null) === nextPath && target.title === nextTitle) return state
return {
...state,