The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): refuse to stream a file: URL that encodes a separator
emozilla45e252295c51
diff --git a/apps/desktop/src/lib/browser-file-urls.test.ts b/apps/desktop/src/lib/browser-file-urls.test.tsindex 14bf507bb58..043467db103 100644--- a/apps/desktop/src/lib/browser-file-urls.test.ts+++ b/apps/desktop/src/lib/browser-file-urls.test.ts@@ -90,3 +90,15 @@ describe.each(FILES)('a Webapp file under $dir', ({ dir, native }) => {expect(Object.fromEntries(src.searchParams)).toEqual({ path: clip, profile: 'default', ticket: 'stream-ticket' })})})++it('refuses to stream a file URL that encodes a separator', async () => {+ // The gateway would decode the separator into another path segment, so the clip could be+ // a different file than the one its label names.+ for (const clip of ['file:///C:/Users/me/a%2F..%2Fclip.mp4', 'file:///C:/Users/me/a%5Cclip.mp4']) {+ await expect(window.hermesDesktop.getGatewayFileStreamUrl!({ ...OWNER, path: clip })).rejects.toThrow(+ 'does not name one file'+ )+ }++ expect(requests).toEqual([])+})diff --git a/apps/desktop/src/lib/browser-files.ts b/apps/desktop/src/lib/browser-files.tsindex 2b35a072453..abc83dda61c 100644--- a/apps/desktop/src/lib/browser-files.ts+++ b/apps/desktop/src/lib/browser-files.ts@@ -1,3 +1,5 @@+import { fileUrlToNativePath } from '@hermes/shared'+import type { HermesApiRequest } from '@/global'import { translateNow } from '@/i18n'import { requireBrowserConnection } from '@/lib/browser-connection'@@ -64,6 +66,12 @@ export function createBrowserFilesBridge({getGatewayFileStreamUrl: async payload => {requireBrowserConnection(payload.connectionId)+ // The gateway decodes an encoded separator into another path segment; stream only a+ // file: URL the shared parser reads, so the clip is the file its label names.+ if (/^file:/i.test(payload.path) && fileUrlToNativePath(payload.path) === null) {+ throw new Error(`${payload.path} does not name one file`)+ }+return (await fileEndpointUrl(bootstrap, 'stream', {path: payload.path,profile: payload.profile ?? currentProfile()