mirror of
https://github.com/stablyai/orca.git
synced 2026-10-15 00:02:48 +00:00
Guard remote runtime PTY id decoding
This commit is contained in:
@@ -27,6 +27,13 @@ describe('remote runtime terminal ids', () => {
|
||||
expect(getRemoteRuntimePtyEnvironmentId('remote:terminal-1')).toBeNull()
|
||||
expect(getRemoteRuntimeTerminalHandle('remote:terminal-1')).toBe('terminal-1')
|
||||
})
|
||||
|
||||
it('treats malformed encoded ids as invalid instead of throwing', () => {
|
||||
const malformed = 'remote:%E0%A4%A@@terminal-1'
|
||||
|
||||
expect(getRemoteRuntimePtyEnvironmentId(malformed)).toBeNull()
|
||||
expect(getRemoteRuntimeTerminalHandle(malformed)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('remote runtime terminal data subscriptions', () => {
|
||||
|
||||
@@ -46,9 +46,13 @@ export function parseRemoteRuntimePtyId(ptyId: string): RemoteRuntimePtyIdParts
|
||||
if (separatorIndex === -1) {
|
||||
return { environmentId: null, handle: rest }
|
||||
}
|
||||
return {
|
||||
environmentId: decodeURIComponent(rest.slice(0, separatorIndex)),
|
||||
handle: decodeURIComponent(rest.slice(separatorIndex + REMOTE_PTY_OWNER_SEPARATOR.length))
|
||||
try {
|
||||
return {
|
||||
environmentId: decodeURIComponent(rest.slice(0, separatorIndex)),
|
||||
handle: decodeURIComponent(rest.slice(separatorIndex + REMOTE_PTY_OWNER_SEPARATOR.length))
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user