Skip to content

Commit

Permalink
Escape single quotes when launching a script by path
Browse files Browse the repository at this point in the history
Since we surround it with single quotes.
  • Loading branch information
andyleejordan committed Nov 17, 2022
1 parent 015fb46 commit 76cfca3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Management.Automation;
Expand Down Expand Up @@ -112,7 +112,7 @@ internal async Task LaunchScriptAsync(string scriptToLaunch)
{
// For a saved file we just execute its path (after escaping it).
command = PSCommandHelpers.BuildDotSourceCommandWithArguments(
string.Concat("'", scriptToLaunch, "'"), _debugStateService?.Arguments);
$"'{scriptToLaunch.Replace("'", "''")}'", _debugStateService?.Arguments);
}
else // It's a URI to an untitled script, or a raw script.
{
Expand Down

0 comments on commit 76cfca3

Please sign in to comment.