Skip to content

Commit

Permalink
Escape paths w/single quotes before passing to powershell in sq strin…
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeithhill authored Jul 10, 2018
1 parent 64dde58 commit 040c216
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import Settings = require("./settings");
import utils = require("./utils");

export class PowerShellProcess {
public static escapeSingleQuotes(pspath: string): string {
return pspath.replace(new RegExp("'", "g"), "''");
}

public onExited: vscode.Event<void>;
private onExitedEmitter = new vscode.EventEmitter<void>();
Expand Down Expand Up @@ -52,8 +55,8 @@ export class PowerShellProcess {
: "";

this.startArgs +=
`-LogPath '${editorServicesLogPath}' ` +
`-SessionDetailsPath '${this.sessionFilePath}' ` +
`-LogPath '${PowerShellProcess.escapeSingleQuotes(editorServicesLogPath)}' ` +
`-SessionDetailsPath '${PowerShellProcess.escapeSingleQuotes(this.sessionFilePath)}' ` +
`-FeatureFlags @(${featureFlags})`;

const powerShellArgs = [
Expand All @@ -68,7 +71,7 @@ export class PowerShellProcess {

powerShellArgs.push(
"-Command",
"& '" + startScriptPath + "' " + this.startArgs);
"& '" + PowerShellProcess.escapeSingleQuotes(startScriptPath) + "' " + this.startArgs);

let powerShellExePath = this.exePath;

Expand Down
2 changes: 1 addition & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class SessionManager implements Middleware {
`-HostProfileId 'Microsoft.VSCode' ` +
`-HostVersion '${this.hostVersion}'` +
`-AdditionalModules @('PowerShellEditorServices.VSCode') ` +
`-BundledModulesPath '${this.bundledModulesPath}'` +
`-BundledModulesPath '${PowerShellProcess.escapeSingleQuotes(this.bundledModulesPath)}'` +
`-EnableConsoleRepl ` +
`-LanguageServicePipeName LanguageService_${id}.pipe ` +
`-DebugServicePipeName DebugService_${id}.pipe `;
Expand Down

0 comments on commit 040c216

Please sign in to comment.