Guard remote runtime PTY id decoding (#3626)
This commit is contained in:
parent
ddbb6a1e7d
commit
7a8b10bd7d
|
|
@ -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', () => {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue