Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 040c216

Browse files
Escape paths w/single quotes before passing to powershell in sq strings (#1411)
Fix #1404
1 parent 64dde58 commit 040c216

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

‎src/process.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import Settings = require("./settings");
1313
import utils = require("./utils");
1414

1515
export class PowerShellProcess {
16+
public static escapeSingleQuotes(pspath: string): string {
17+
return pspath.replace(new RegExp("'", "g"), "''");
18+
}
1619

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

5457
this.startArgs +=
55-
`-LogPath '${editorServicesLogPath}' ` +
56-
`-SessionDetailsPath '${this.sessionFilePath}' ` +
58+
`-LogPath '${PowerShellProcess.escapeSingleQuotes(editorServicesLogPath)}' ` +
59+
`-SessionDetailsPath '${PowerShellProcess.escapeSingleQuotes(this.sessionFilePath)}' ` +
5760
`-FeatureFlags @(${featureFlags})`;
5861

5962
const powerShellArgs = [
@@ -68,7 +71,7 @@ export class PowerShellProcess {
6871

6972
powerShellArgs.push(
7073
"-Command",
71-
"& '" + startScriptPath + "' " + this.startArgs);
74+
"& '" + PowerShellProcess.escapeSingleQuotes(startScriptPath) + "' " + this.startArgs);
7275

7376
let powerShellExePath = this.exePath;
7477

‎src/session.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class SessionManager implements Middleware {
173173
`-HostProfileId 'Microsoft.VSCode' ` +
174174
`-HostVersion '${this.hostVersion}'` +
175175
`-AdditionalModules @('PowerShellEditorServices.VSCode') ` +
176-
`-BundledModulesPath '${this.bundledModulesPath}'` +
176+
`-BundledModulesPath '${PowerShellProcess.escapeSingleQuotes(this.bundledModulesPath)}'` +
177177
`-EnableConsoleRepl ` +
178178
`-LanguageServicePipeName LanguageService_${id}.pipe ` +
179179
`-DebugServicePipeName DebugService_${id}.pipe `;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /