Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowershellArgumentNeedsEscaping does not account for a single quoted string #1608

Closed
JustinGrote opened this issue Oct 29, 2021 · 1 comment · Fixed by #1611
Closed

PowershellArgumentNeedsEscaping does not account for a single quoted string #1608

JustinGrote opened this issue Oct 29, 2021 · 1 comment · Fixed by #1611
Labels

Comments

@JustinGrote
Copy link
Collaborator

JustinGrote commented Oct 29, 2021

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.

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Status: In PR labels Oct 30, 2021
@ghost ghost added the Status: In PR label Nov 1, 2021
@JustinGrote JustinGrote changed the title PowershellArgumentNeedsEscaping does not account for a single quoted string PowershellArgumentNeedsEscaping does not account for a single quoted string - MOVED TO 1611 Nov 2, 2021
@JustinGrote JustinGrote changed the title PowershellArgumentNeedsEscaping does not account for a single quoted string - MOVED TO 1611 PowershellArgumentNeedsEscaping does not account for a single quoted string Nov 2, 2021
@andyleejordan andyleejordan added Area-Debugging Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! Needs: Maintainer Attention Maintainer attention needed! labels Nov 3, 2021
@ghost ghost added Status: Fixed and removed Status: In PR labels Nov 3, 2021
@andyleejordan andyleejordan moved this to Todo in Sea Biscuit Jan 24, 2022
@andyleejordan andyleejordan moved this from Todo to Done in Sea Biscuit Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants