-
Notifications
You must be signed in to change notification settings - Fork 237
Closed
Closed
Copy link
Labels
Description
PowerShellEditorServices/src/PowerShellEditorServices/Utility/StringEscaping.cs
Lines 17 to 33 in 8c568bc
public static bool PowerShellArgumentNeedsEscaping(string argument) | |
{ | |
foreach (char c in argument) | |
{ | |
switch (c) | |
{ | |
case '\'': | |
case '"': | |
case '|': | |
case '&': | |
case ';': | |
case ':': | |
case char w when char.IsWhiteSpace(w): | |
return true; | |
} | |
} | |
Will match true on 'test string'
, it should match false. The ' case needs an additional check to make sure the argument isn't already enclosed in quotes.