mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
109216 Sanitize Process Environment before spawning terminal instance
This commit is contained in:
parent
72aa675fc9
commit
2b81396e0a
|
@ -14,6 +14,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
|||
import { optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
import { ITerminalEnvironment } from 'vs/platform/terminal/common/terminal';
|
||||
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';
|
||||
|
||||
const TERMINAL_TITLE = nls.localize('console.title', "VS Code Console");
|
||||
|
||||
|
@ -71,8 +72,8 @@ export class WindowsExternalTerminalService extends ExternalTerminalService impl
|
|||
}
|
||||
|
||||
return new Promise<void>((c, e) => {
|
||||
const env = cwd ? { cwd: cwd } : undefined;
|
||||
const child = spawner.spawn(command, cmdArgs, env);
|
||||
const env = getSanitizedEnvironment(process);
|
||||
const child = spawner.spawn(command, cmdArgs, { cwd, env });
|
||||
child.on('error', e);
|
||||
child.on('exit', () => c());
|
||||
});
|
||||
|
@ -91,7 +92,7 @@ export class WindowsExternalTerminalService extends ExternalTerminalService impl
|
|||
];
|
||||
|
||||
// merge environment variables into a copy of the process.env
|
||||
const env = Object.assign({}, process.env, envVars);
|
||||
const env = Object.assign({}, getSanitizedEnvironment(process), envVars);
|
||||
|
||||
// delete environment variables that have a null value
|
||||
Object.keys(env).filter(v => env[v] === null).forEach(key => delete env[key]);
|
||||
|
@ -319,8 +320,8 @@ export class LinuxExternalTerminalService extends ExternalTerminalService implem
|
|||
|
||||
return new Promise<void>((c, e) => {
|
||||
execPromise.then(exec => {
|
||||
const env = cwd ? { cwd } : undefined;
|
||||
const child = spawner.spawn(exec, [], env);
|
||||
const env = getSanitizedEnvironment(process);
|
||||
const child = spawner.spawn(exec, [], { cwd, env });
|
||||
child.on('error', e);
|
||||
child.on('exit', () => c());
|
||||
});
|
||||
|
@ -328,6 +329,12 @@ export class LinuxExternalTerminalService extends ExternalTerminalService implem
|
|||
}
|
||||
}
|
||||
|
||||
function getSanitizedEnvironment(process: NodeJS.Process) {
|
||||
const env = process.env;
|
||||
sanitizeProcessEnvironment(env);
|
||||
return env;
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to turn OS errors into more meaningful error messages
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue